API Docs for: 0.8.0
Show:

UserService Class

Service for performing user specific operations.

Methods

_isFieldInUse

(
  • value
  • field
  • [options]
  • cb
)
private

Indicates if there exists a user with the specified property value. The field is expected to be a string value. The values will be compare with case ignored.

Parameters:

  • value String
  • field String
  • [options] Object optional
    • [exclusionId] String optional
  • cb Function

determineUserSiteScope

(
  • accessLevel
  • siteId
)

Parameters:

  • accessLevel Integer
  • siteId String

Returns:

:

findByAccessLevel

(
  • level
  • [options]
  • cb
)

Retrieves users by their access level (role)

Parameters:

  • level Integer

    The admin level of the users to find

  • [options] Object optional

    The search options

    • [select={}] Object optional

      The fields to return

    • [orderBy] Array optional

      The order to return the results in

    • [limit] Integer optional

      The maximum number of results to return

    • [offset=0] Offset optional

      The number of results to skip before returning results.

  • cb Function

    (Error, Array) A callback that takes two parameters: an error, if occurred, and the second is an array of User objects.

getAdminOptions

(
  • session
  • ls
)
Array

Retrieves the available access privileges to assign to a user

Parameters:

  • session Object

    The current session object

  • ls Localization

    The localization object

Returns:

Array:

getAuthors

(
  • objArry
  • cb
)

Gets the full names for the supplied authors

Parameters:

  • objArry Array

    An array of user object

  • cb Function

    (Error, Array)

getByUsernameOrEmail

(
  • usernameOrEmail
  • [options]
  • cb
)

Parameters:

  • usernameOrEmail String
  • [options] Object optional

    See UserService#getSingle

  • cb Function

    (Error, object) The user object

getEditorSelectList

(
  • currId
  • cb
)
deprecated

Defined in include/service/entities/user_service.js:184

Deprecated: since 0.4.0

Retrieves a select list (id/name) of available system editors

Parameters:

  • currId String

    The Id to be excluded from the list.

  • cb Function

    (Error, Array) A callback that takes two parameters. The first is an error, if exists, the second is an array of objects that represent the editor select list.

getExistingUsernameEmailCounts

(
  • username
  • email
  • [id]
  • cb
)

Gets the total counts of a username and email in both the user and unverified_user collections

Parameters:

  • username String
  • email String
  • [id] String optional

    User object Id to exclude from the search

  • cb Function

    (Error, object)

getFormattedName

(
  • user
)
String static

Takes the specified user object and formats the first and last name.

Parameters:

  • user Object

    The user object to extract a name for.

Returns:

String:

The user's full name

getFullName

(
  • userId
  • cb
)

Gets the full name of a user

Parameters:

  • userId String

    The object Id of the user

  • cb Function

    (Error, string)

getWriterOrEditorSelectList

(
  • currId
  • [getWriters=false]
  • cb
)

Retrieves a select list (id/name) of available system writers or editors

Parameters:

  • currId String

    The Id to be excluded from the list.

  • [getWriters=false] Boolean optional

    Whether to retrieve all writers or just editors.

  • cb Function

    A callback that takes two parameters. The first is an error, if exists, the second is an array of objects that represent the editor select list.

hasAccessLevel

(
  • uid
  • accessLevel
  • cb
)

Verifies if a user has the provided access level or higher

Parameters:

  • uid String

    The user's object Id

  • accessLevel Number

    The access level to test against

  • cb Function

    Callback function

isUsernameInUse

(
  • username
  • [options]
  • cb
)

Indicates if there exists a user with the specified username value. The field is expected to be a string value. The values will be compare with case ignored.

Parameters:

  • username String
  • [options] Object optional
    • [exclusionId] String optional
  • cb Function

isUsernameInUse

(
  • email
  • [options]
  • cb
)

Indicates if there exists a user with the specified email value. The field is expected to be a string value. The values will be compare with case ignored.

Parameters:

  • email String
  • [options] Object optional
    • [exclusionId] String optional
  • cb Function

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • service UserService

      An instance of the service that triggered the event that called this handler

    • data Object

      The DTO

    • object Object

      The entity object to be persisted

  • cb Function

    (Error) A callback that takes a single parameter: an error if occurred

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • service UserService

      An instance of the service that triggered the event that called this handler

    • data Object
  • cb Function

    (Error) A callback that takes a single parameter: an error if occurred

isUserNameOrEmailTaken

(
  • username
  • email
  • id
  • cb
)

Checks to see if a proposed user name or email is already in the system

Parameters:

  • username String
  • email String
  • id String

    User object Id to exclude from the search

  • cb Function

    Callback function

removePassword

(
  • context
  • cb
)
static

Strips the password from one or more user objects when passed a valid base object service event context

Parameters:

  • context Object
    • data Object

      The DTO that was provided for persistence

    • service UserService

      An instance of the service that triggered the event that called this handler

  • cb Function

    A callback that takes a single parameter: an error if occurred

sendPasswordResetEmail

(
  • user
  • passwordReset
  • cb
)
deprecated

Sends a password reset email to a user

Parameters:

  • user Object

    A user object

  • passwordReset Object

    A password reset object containing the verification code

  • cb Function

    (Error)

sendVerificationEmail

(
  • user
  • cb
)

Sends a verification email to an unverified user

Parameters:

  • user Object

    A user object

  • cb Function

    Callback function

validate

(
  • context
  • cb
)

Parameters:

  • context Object
    • data Object

      The DTO that was provided for persistence

    • service UserService

      An instance of the service that triggered the event that called this handler

  • cb Function

    (Error) A callback that takes a single parameter: an error if occurred

validate

(
  • context
  • cb
)
static

Parameters:

  • context Object
    • data Object

      The DTO that was provided for persistence

    • service UserService

      An instance of the service that triggered the event that called this handler

  • cb Function

    A callback that takes a single parameter: an error if occurred

Properties

TYPE

String private static

UNVERIFIED_TYPE

String private static