Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "user/user.service"

Index

Variables

Const PASSWORD_MIN_LENGTH

PASSWORD_MIN_LENGTH: 6 = 6

Const PASSWORD_RECOVERY_LINK_MAX_AGE

PASSWORD_RECOVERY_LINK_MAX_AGE: number = 24 * 3600000

Const PASSWORD_RECOVERY_TOKENS_FILE

PASSWORD_RECOVERY_TOKENS_FILE: string = path.join(configUtils.dataPathAbsolute(), "password-recovery.json")

Const USERNAME_MIN_LENGTH

USERNAME_MIN_LENGTH: 3 = 3

Const USERNAME_VALIDATION_REGEX

USERNAME_VALIDATION_REGEX: RegExp = /^[a-zA-Z][-\w]+$/g

Functions

authenticate

  • authenticate(name: any, password: any): Promise<any>
  • Authenticates against a user name and password, and updates the session accordingly

    Parameters

    • name: any

      name

    • password: any

      clear password (will be hashed & compared to the DB entry)

    Returns Promise<any>

    The models.User, or false if the authentication failed

deleteUser

  • deleteUser(user: any): Promise<object>
  • Deletes an user, but only if it doesn't have any entries.

    Parameters

    • user: any

    Returns Promise<object>

findById

  • findById(id: any): Promise<any>

findByName

  • findByName(name: any): Promise<any>

findUsers

  • findUsers(options?: any): Promise<any>
  • Fetches users

    Parameters

    • Default value options: any = {}

    Returns Promise<any>

hashPassword

  • hashPassword(password: any, salt: any): string

loadPasswordRecoveryCache

  • loadPasswordRecoveryCache(app: any): Promise<void>

refreshUserReferences

  • refreshUserReferences(user: any): Promise<void>
  • Refreshes various models that cache user name and/or title. Call this after changing the name or title of an user.

    Parameters

    • user: any

    Returns Promise<void>

register

  • register(email: any, name: any, password: any): Promise<bookshelf.Model<any> | string>
  • Registers a new user

    Parameters

    • email: any

      email

    • name: any

      name

    • password: any

      unencrypted password (will be hashed before storage)

    Returns Promise<bookshelf.Model<any> | string>

    the created user, or an error message

searchByName

  • searchByName(fragment: any, options?: any): Promise<any>
  • Search users by name

    Parameters

    • fragment: any

      a fragment of the user name.

    • Default value options: any = {}

    Returns Promise<any>

    the users with names matching the query.

    Note: all searches will be case-sensitive if developing with SQLite.

sendPasswordRecoveryEmail

  • sendPasswordRecoveryEmail(app: any, email: any): Promise<void>

setPassword

  • setPassword(user: any, password: any): string | true
  • Sets a password to a User

    Parameters

    • user: any

      User model

    • password: any

      New password, in clear form

    Returns string | true

    true, or an error message

setPasswordUsingToken

  • setPasswordUsingToken(app: any, token: any, password: any): Promise<string | true>
  • Parameters

    • app: any
    • token: any
    • password: any

    Returns Promise<string | true>

    true or an error message

validatePassword

  • validatePassword(password: any): string | true
  • Validates the given password

    Parameters

    • password: any

    Returns string | true

    true, or an error message

validatePasswordRecoveryToken

  • validatePasswordRecoveryToken(app: any, token: any): boolean

Generated using TypeDoc