Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UserService

Hierarchy

Index

Constructors

constructor

Methods

activateTotp

  • activateTotp(): Promise<IResult<null>>
  • Returns Promise<IResult<null>>

    Returns a status object.

    Example

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

create

  • Parameters

    Returns Promise<IResult<IUser>>

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

    Example

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

current

  • Returns Promise<IResult<IUser>>

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

    Example

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

currentWithEffectiveRoles

  • Returns Promise<IResult<ICurrentUser>>

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

    Example

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

delete

  • Parameters

    Returns Promise<IResult<null>>

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

    Example

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

detail

  • Parameters

    • entityOrId: string | number | IUser

    Returns Promise<IResult<IUser>>

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

    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.

generateTotpSecret

  • Returns Promise<IResult<ITotp>>

    Returns the secret and an URL to a QR Code.

    Example

    
       (async () => {
         const {data, res} = await userService.generateTotpSecret();
         console.log(secret);
      })();
    

getActivityTotp

  • Returns Promise<IResult<ITotpStatus>>

    Returns an object of ITotpStatus if it is active.

    Example

    
       (async () => {
         const {data, res} = await userService.getActivityTotp();
         console.log(data.isActive);
      })();
    

hasAllRoles

  • hasAllRoles(user: IUser, roleIds: string[]): boolean
  • Parameters

    • user: IUser
    • roleIds: string[]

    Returns boolean

hasAnyRole

  • hasAnyRole(user: IUser, roleIds: string[]): boolean
  • Parameters

    • user: IUser
    • roleIds: string[]

    Returns boolean

hasRole

  • hasRole(user: IUser, roleId: string): any
  • Parameters

    • user: IUser
    • roleId: string

    Returns any

inventoryAssignment

  • Parameters

    • entityOrId: string | number | IUser

    Returns UserInventoryRoleService

    Returns UserInventoryRoleService object that is related with given User.

    Example

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

list

  • Parameters

    • Default value filter: object = {}

    Returns Promise<IResultList<IUser>>

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

    Example

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

list$

  • Parameters

    Returns Observable<IUser[]>

    Data wrapped as Observable.

    Example

    
      const list$ = userInventoryRoleService.list$();
      list$.subscribe((data) => console.log(data));
    

    Deprecated This function will be removed soon in favor of decoupling this library from rxjs. Use Realtime for realtime connection and rxjs defer() or from() to composite an observable on your own.

resetPassword

  • Parameters

    Returns Promise<IResult<null>>

    Returns a request result object.

    Example

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

savePhoneNumber

  • Parameters

    • phoneNumber: string

    Returns Promise<IResult<ICurrentUser>>

    Server response and data with updated current user object.

sendPasswordResetMail

  • sendPasswordResetMail(email: string, tenantId?: string): Promise<IResult<null>>
  • Parameters

    • email: string
    • Optional tenantId: string

    Returns Promise<IResult<null>>

    Returns a request result object.

    Example

      const email = 'user@example.com';
      const tenantId = 't123456';
    
      (async () => {
        const { res, data } = await userService.sendPasswordResetMail(email, tenantId);
      })();
    

totpRevokeSecret

  • Parameters

    Returns Promise<IResult<null>>

    Status object

update

  • Parameters

    Returns Promise<IResult<IUser>>

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

    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'.

updateCurrent

  • Parameters

    Returns Promise<IResult<IUser>>

    Returns promise object resolved with the IUser wrapped by IResult

verifyTFACode

  • verifyTFACode(pin: string): Promise<IResult<null>>
  • Parameters

    • pin: string

    Returns Promise<IResult<null>>

    Returns a status object.

    Example

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

verifyTotpCode

  • verifyTotpCode(code: any): Promise<IResult<null>>
  • Parameters

    • code: any

    Returns Promise<IResult<null>>

    Returns a status object.

    Example

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

Generated using TypeDoc