Class Auth0User

A user stored in a Auth0 User Pool.

Hierarchy (view full)

Constructors

  • Object initialization, setting all the default values.

    Parameters

    • OptionalnewData: any

      the data to load, optional

    • Optionaloptions: any

      custom options to apply; they will depend on the child resource

      Usually, there is no need to implement the constructor; implicitly, it will call the load of the child resource and therefore loading all the resources with default values. If needed, this is the suggested implementation:

      super();
      this.load(x);
      // ...

    Returns Auth0User

Properties

attributes: {
    [attribute: string]: any;
}

The user's custom attributes.

email: string

The email address of the user.

emailVerified: boolean

Whether the email address of the user is verified.

groups: string[]

The list of groups the user is part of.

name: string

The fullname of the user.

nickname: string

The nickname of the user.

picture: string

The URI or URL to the user's picture.

preferences: {
    [preference: string]: any;
}

The user's custom preferences.

updatedAt: string

The timestamp of last update of the user.

userId: string

The ID of the user (sub).

Methods

  • Return an attribute in a cleaned standard that force-cast the element.

    Parameters

    • origin: any

      the origin attribute, to cast

    • castFunction: ((x: any) => any)

      the cast function, e.g. Boolean, Number, String, x => new CustomClass(x), etc.

        • (x): any
        • Parameters

          • x: any

          Returns any

    • OptionaldefaultVal: any

      if set, the fallback value instead of null

    Returns any

    cleaned attribute

  • Return an array in a cleaned standard that force-cast each element, keeping only the valid ones.

    Parameters

    • origin: any[]

      the origin array, to cast and check

    • castFunction: ((x: any) => any)

      the cast function, e.g. x => String(x) or x => new CustomClass(x)

        • (x): any
        • Parameters

          • x: any

          Returns any

    • OptionaldefaultVal: any

      if set, the fallback value instead of null

    Returns any[]

    cleaned array

  • Whether the user is part of the administrators group.

    Returns boolean

  • Whether the user is part of the robots group.

    Returns boolean

  • Load the attributes from an already existing resource and then force some attributes to assume safeData values. The function is usually used in the back-end to mix together db data with new data, without the risk of changing ids and other attributes which are managed in appositely curated scenario.

    Parameters

    • newData: any

      the data to load

    • safeData: any

      the attributes to force to specific values

    • Optionaloptions: any

      custom options to apply; they will depend on the child resource

      Typical implementation:

      super.safeLoad(newData, safeData);
      this.keyAttr = safeData.keyAttr;
      this.importantAttr = safeData.importantAttr;
      this.isDraft = safeData.isDraft;
      // ...

      Note well: there is no need to call this.load(), since it's implicitly called from super.safeLoad(), which will anyway use the child version of the method.

    Returns void