Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UserService

description

This service allows for managing users.

Hierarchy

Index

Constructors

constructor

Methods

changePassword

  • Set a new password.

    example
     const newPassword: IResetPassword = {
        newPassword: 'myNewPassword',
        passwordStrength: PasswordStrength.GREEN,
        token: '123123ASDAWERER@#!WEDS$@#!WADA#A#EA#EA#EA'
      };
    
       (async () => {
         const {data, res} = await userService.changePassword(newPassword);
      })();
    

    Parameters

    • newPassword: IResetPassword

      New password with password reset token and strength.

    Returns Promise<IResult<null>>

    Returns a status object.

create

  • Creates a new user.

    example
    
     const userObject: IUser = {
       userName: "newUser",
       password: "userPassword12!@"
     };
    
     (async () => {
       const {data, res} = await userService.create(userObject);
     })();
    

    Parameters

    • entity: IUser

      User object.

    Returns Promise<IResult<IUser>>

    Returns promise object that is resolved with the details of newly created user.

current

  • Gets user that is currently logged in.

    example
    
       (async () => {
         const {data, res} = await userService.current();
      })();
    

    Returns Promise<IResult<ICurrentUser>>

    Returns promise object that is resolved with the ICurrenUser wrapped by IResult.

delete

  • Removes user.

    example
    
       const userId: string = "uniqueUserId";
    
       (async () => {
         const {data, res} = await userService.delete(userGroupId);
      })();
    

    Parameters

    • entityOrId: string | number | IIdentified

      User's id or user object.

    Returns Promise<IResult<null>>

    Returns promise object that is resolved with the IResult of null.

detail

  • Gets the details of given user.

    example
    
       const userId: number = 1;
    
       (async () => {
         const {data, res} = await userService.detail(userId);
      })();
    

    User password is never returned in GET response. Authentication mechanism is provided by another interface.

    Parameters

    • entityOrId: string | number | IUser

      User's id or user object.

    Returns Promise<IResult<IUser>>

    Returns promise object that is resolved with the IUser wrapped by IResult.

inventoryAssignment

  • Create instance of User Inventory Role Service related with given User.

    example
    
       const userId: string = "uniqueUserId";
    
       const userInventoryRoleService = userService.inventoryAssignment(userGroupId);
       (async () => {
         const {data, res} = await userInventoryRoleService.create(...);
      })();
    

    Parameters

    • entityOrId: string | number | IUser

      User's id or user object.

    Returns UserInventoryRoleService

    Returns UserInventoryRoleService object that is related with given User.

list

  • Gets the list of users filtered by parameters.

    example
    
     const filter: object = {
        pageSize: 100,
        withTotalPages: true
      };
    
      (async () => {
        const {data, res, paging} = await userService.list(filter);
      })();
    

    Parameters

    • Default value filter: object = {}

      Object containing filters for querying users.

    Returns Promise<IResultList<IUser>>

    Returns promise object that is resolved with the IUser wrapped by IResultList.

resetPassword

  • resetPassword(email: string): Promise<IResult<null>>
  • Sends a new password to the given email.

    example
    
       (async () => {
         const {data, res} = await userService.current();
      })();
    

    Parameters

    • email: string

      The email address to send the reset mail to.

    Returns Promise<IResult<null>>

    Returns a status object.

update

  • Updates user data.

    example
    
     const partialUpdateObject: Partial<IUser> = {
        "id" : "myuser",
        "userName" : "newUserName",
        "email": "newUserEmail@example.com"
        ...
      }
    
     (async () => {
       const {data, res} = await userService.update(partialUpdateObject);
     })();
    

    When user is updated with changed permissions or groups, suitable audit record is created with type 'User' and activity 'User updated'.

    Parameters

    • entity: Partial<IUser>

      User is partially updatable.

    Returns Promise<IResult<IUser>>

    Returns promise object that is resolved with the saved user object.

updateCurrent

  • Updates the current user

    Parameters

    • user: IUser

      The user object with the properties to be updated

    Returns Promise<IResult<ICurrentUser>>

    Returns promise object resolved with the ICurrentUser wrapped by IResult

verifyTFACode

  • verifyTFACode(pin: string): Promise<IResult<null>>
  • Verifies TFA code. If invoked with string '0', new TFA code will be sent.

    example
    
       (async () => {
         const {data, res} = await userService.verifyTFACode('123123');
      })();
    

    Parameters

    • pin: string

      The code to verify.

    Returns Promise<IResult<null>>

    Returns a status object.

Generated using TypeDoc