Class UserFactory

Creates a new instance of the managed type of this factory

Hierarchy

Constructors

  • Creates a new user object

    Returns

    A new created user

    Parameters

    • Optional properties: {
          [property: string]: any;
      }

      Additional properties which will be applied to the created instance

      • [property: string]: any

    Returns model.User

Properties

db: EntityManager = ...

The owning EntityManager where this factory belongs to

managedType: ManagedType<model.User> = ...

The managed type of this factory

methods: {
    [methodName: string]: any;
} = ...

Methods that are added to object instances This property is an alias for this factory type prototype

Name

methods

Type declaration

  • [methodName: string]: any
prototype: model.User = ...
type: Class<model.User> = ...
DefaultOptions: {
    facebook: {
        height: number;
        path: string;
        scope: string;
        width: number;
    };
    github: {
        height: number;
        path: string;
        scope: string;
        width: number;
    };
    google: {
        height: number;
        path: string;
        scope: string;
        width: number;
    };
    linkedin: {
        height: number;
        path: string;
        scope: string;
        width: number;
    };
    salesforce: {
        height: number;
        scope: string;
        width: number;
    };
    twitter: {
        height: number;
        version: number;
        width: number;
    };
} = ...

Property

default properties

Property

default oauth properties for Google

Property

default oauth properties for Facebook

Property

default oauth properties for GitHub

Property

default oauth properties for Twitter

Property

default oauth properties for LinkedIn

Property

default oauth properties for Salesforce

Type declaration

  • facebook: {
        height: number;
        path: string;
        scope: string;
        width: number;
    }
    • height: number
    • path: string
    • scope: string
    • width: number
  • github: {
        height: number;
        path: string;
        scope: string;
        width: number;
    }
    • height: number
    • path: string
    • scope: string
    • width: number
  • google: {
        height: number;
        path: string;
        scope: string;
        width: number;
    }
    • height: number
    • path: string
    • scope: string
    • width: number
  • linkedin: {
        height: number;
        path: string;
        scope: string;
        width: number;
    }
    • height: number
    • path: string
    • scope: string
    • width: number
  • salesforce: {
        height: number;
        scope: string;
        width: number;
    }
    • height: number
    • scope: string
    • width: number
  • twitter: {
        height: number;
        version: number;
        width: number;
    }
    • height: number
    • version: number
    • width: number

Accessors

  • get me(): null | model.User
  • The current logged in user, or null if the user is not logged in

    Returns null | model.User

Methods

  • Add a method to instances of this factories type

    Returns

    Parameters

    • name: string

      The method name to add

    • fn: Function

      The Method to add

    Returns void

  • Adds methods to instances of this factories type

    Returns

    Parameters

    • methods: {
          [name: string]: Function;
      }

      The methods to add

      • [name: string]: Function

    Returns void

  • Sends an email with a link to change the current username

    The user is identified by their current username and password. The username must be a valid email address.

    Returns

    Parameters

    • username: string

      Current username (email) to identify the user

    • newUsername: string

      New username (email) to change the current username to

    • password: string

      The current password of the user. Has to be passed to the function for security reason

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<any>

  • Creates a new instance and sets the DatabaseObject to the given json

    Returns

    instance

    Parameters

    Returns model.User

  • Loads the instance for the given id, or null if the id does not exists.

    Returns

    A Promise that will be fulfilled when the asynchronous operation completes.

    Parameters

    • id: string

      The id to query

    • Optional options: {
          depth?: number | boolean;
          local?: boolean;
          refresh?: boolean;
      }

      The load options

      • Optional depth?: number | boolean

        The object depth which will be loaded. Depth 0 loads only this object, true loads the objects by reachability.

      • Optional local?: boolean

        Indicates whether the local copy (from the entity manager) of an object should be returned if it exists. This value might be stale.

      • Optional refresh?: boolean

        Indicates whether the object should be revalidated (cache bypass).

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<null | model.User>

  • Log in the user with the given username and password and starts a user session

    Returns

    Parameters

    • username: string

      The username of the user

    • password: string

      The password of the user

    • Optional loginOption: boolean | Function | LoginOption

      The default keeps the user logged in over multiple sessions

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with Facebook via OAuth

    Prompts the user for the Facebook login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/facebook and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with GitHub via OAuth

    Prompts the user for the GitHub login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/github and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with Google via OAuth

    Prompts the user for the Google login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/google and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with LinkedIn via OAuth

    Prompts the user for the LinkedIn login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/linkedin and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with Salesforce via OAuth

    Prompts the user for the Salesforce login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/salesforce and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Log in the user assiciated with the given token and starts a user session.

    Returns

    Parameters

    • token: string

      The user token.

    • Optional loginOption: boolean | Function | LoginOption

      The default keeps the user logged in over multiple sessions

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Logs the user in with Twitter via OAuth

    Prompts the user for the Twitter login in a new window. Before using OAuth you need to setup your application on the provider website, add the redirect uri: https://example.net/db/User/OAuth/twitter and copy the client id and the client secret to your Baqend dashboard settings. When the returned promise succeeds the user is logged in.

    Returns

    Parameters

    • options: OAuthOptions
    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Log out the current logged in user and ends the active user session

    Returns

    Parameters

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<any>

  • Creates a new instance of the factory type

    Returns

    A new created instance of *

    Instance

    Parameters

    • Rest ...args: any[]

      Constructor arguments used for instantiation

    Returns model.User

  • Creates a new instance of the factory type

    Returns

    A new created instance of T

    Parameters

    • Optional args: IArguments | any[]

      Constructor arguments used for instantiation, the constructor will not be called when no arguments are passed

    Returns model.User

  • Change the password of the given user

    Returns

    Parameters

    • username: string

      Username to identify the user

    • password: string

      Current password of the user

    • newPassword: string

      New password of the user

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Change the password of a user, which will be identified by the given token from the reset password e-mail

    See

    resetPassword

    Returns

    Parameters

    • token: string

      Token from the reset password e-mail

    • newPassword: string

      New password of the user

    • Optional loginOption: boolean | LoginOption

      The default keeps the user logged in over multiple sessions

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Gets an unloaded reference for the given id.

    Returns

    An unloaded reference to the object with the given id.

    Parameters

    • id: string

      The id of an object to get a reference for.

    Returns model.User

  • Register a new user with the given username and password, if the username is not used by an another user.

    Returns

    The created user object, for the new registered user.

    Parameters

    • user: string | model.User

      The username as a string or a Object, which must contain the username.

    • password: string

      The password for the given user

    • Optional loginOption: boolean | Function | LoginOption

      The default logs the user in after a successful registration and keeps the user logged in over multiple sessions

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<model.User>

  • Requests a perpetual token for the given user

    Only users with the admin role are allowed to request an API token.

    Returns

    Parameters

    • user: model.User

      The user object or id of the user object

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<any>

  • Sends an email with a link to reset the password for the given username

    The username must be a valid email address.

    Returns

    Parameters

    • username: string

      Username (email) to identify the user

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<any>

  • Revoke all created tokens for the given user

    This method will revoke all previously issued tokens and the user must login again.

    Returns

    Parameters

    • user: model.User

      The user object or id of the user object

    • Optional doneCallback: any

      Called when the operation succeed.

    • Optional failCallback: any

      Called when the operation failed.

    Returns Promise<any>

Generated using TypeDoc