Websites v4 docs v5.2.4
    Preparing search index...

    Hierarchy

    • default
      • User
    Index

    Constructors

    Properties

    sessionData: SessionsResponse | null
    allowedUserTypes: string[] = ...
    currentUser: User | undefined
    serializer: (model: any) => any

    serializer is a pure function that takes a model instance and returns a plain object that describes how to convert the model to JSON

    Accessors

    Methods

    • Parameters

      • id: number | null

      Returns Promise<any>

    • Parameters

      • __namedParameters: { channel: string; placeId?: string | null; searchFragment: string }
        • channel: string

          Either 'sales' or 'lettings'

        • OptionalplaceId?: string | null
        • searchFragment: string

          The search path, e.g. from-3-bed/up-to-5-bed/from-300000/up-to-500000

      Returns Promise<SearchesAPIResponse>

    • Retrieves a value from raw API data. Prioritises DBAPI data if available

      Parameters

      • key: string

      Returns any

    • Parameters

      • id: number | null

      Returns Promise<any>

    • Parameters

      • id: number

      Returns Promise<SearchesAPIResponse>

    • Special method to define behaviour of JSON.stringify() on model instance

      Returns any

    • Parameters

      • id: number
      • updatedSearch: SavedSearch

      Returns Promise<SearchesAPIResponse>

    • This will return the currently signed in user if it is present.

      The Session object returned by getServerSession from next-auth must be passed.

      Parameters

      • session: { encryptedCookieToken: string | undefined }

      Returns Promise<User | null>

       const session = await getServerSession(authOptions);
      const user = await User.current(session);
    • Parameters

      • params: { email: string }

      Returns Promise<{ errors: ModelError[] | null; message: string | null }>

    • Parameters

      Returns Promise<
          | { errors: { message: string }[]; message: null }
          | { errors: { message: string; status: number }[]; message: null }
          | { errors: null; message: string },
      >

    • Creates a new user and corresponding lead. Does not sign the user in.

      Parameters

      Returns Promise<RegisterResponse>

      await User.register({
      email: 'myemail@example.com',
      password: 'abc123',
      passwordConfirmation: 'abc123',
      firstName: 'Testuser',
      lastName: 'Testuser',
      agencyId: 12345,
      optInMarketing: false,
      optInTerms: true,
      });

      User registration requires a Bearer token (app verification) via production users api, regardless of the environement. This is handled in the users-api-user-helper.ts.

    • Creates a new user session and instantiates and returns a new User.

      Returns null if sign in was unsuccessful.

      Parameters

      • __namedParameters: { email: string; password: string }

      Returns Promise<User | null>

      const user = await User.signIn({ email: 'myemail@example.com', password: 'abc123' });
      
    • Front end user session verification requires a Bearer token (app verification) via staging users api if in a staging environment. This differs from other flows that always require a Bearer token from production, regardless of environment. This is handled in the users-api-session-helper.ts.

      Parameters

      • encryptedCookieToken: string

      Returns Promise<User | null>