UserService

Description

This class provides methods to manage users.

Constructors

  • Parameters

    • userModel: Model<UserDocument, {}, {}, {}, Document<unknown, {}, UserDocument> & User & Document<any, any, any> & {}, any>

      The user model.

    • mLogger: LogglyService

      The Loggly service.

    • authMiddleware: AuthMiddleware

      The authentication middleware.

    • jwtService: JwtService

      The JWT service.

    Returns UserService

Methods

  • Parameters

    Returns Promise<string>

    • The generated auth token.

    Async

  • Parameters

    • id: string

      The user id.

    Returns Promise<Document<unknown, {}, User> & User & Required<{}>>

    • The user document.

    Async

  • Parameters

    • payload: default

      The change role data.

    Returns Promise<UpdateWriteOpResult>

    • The result of the grant admin operation.

    Async

  • Parameters

    • payload: default

      The change role data.

    Returns Promise<UpdateWriteOpResult>

    • The result of the grant user operation.

    Async

  • Parameters

    Returns Promise<{
        token: string;
        user: TransformedUser;
    }>

    • The logged in user and the token.

    Async

    Throws

    • Throws an error if the username or password is incorrect.
  • Parameters

    Returns Promise<UpdateWriteOpResult>

    • The result of the logout operation.

    Async

  • Parameters

    Returns Promise<UpdateWriteOpResult>

    • The result of the logout all operation.

    Async

  • Parameters

    Returns Promise<StrippedUser>

    • The created user.

    Async

    Throws

    • Throws an exception if the username already exists.
  • Parameters

    • id: string

      The user id.

    • user: User

      The user data.

    Returns Promise<User>

    • The updated user.

    Async

    Throws

    • Throws an exception if the user is not found.