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();
      })();
    

changeCurrentUserPassword

  • changeCurrentUserPassword(newPassword: string, currentUserPassword: string): Promise<IResult<null>>
  • Parameters

    • newPassword: string
    • currentUserPassword: string

    Returns Promise<IResult<null>>

    Returns a result object. During this action if preferred login mode is OAI_SECURE new jwt cookie will be set.

changeUserPassword

  • changeUserPassword(entityOrId: string | number | IUser, newPassword: string, currentUserPassword: string): Promise<IResult<null>>
  • Parameters

    • entityOrId: string | number | IUser
    • newPassword: string
    • currentUserPassword: string

    Returns Promise<IResult<null>>

    Returns a result object.

create

  • create(entity: IUser): Object
  • Parameters

    Returns Object

    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

  • delete(entityOrId: string | number | IIdentified): Object
  • Parameters

    Returns Object

    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

  • detail(entityOrId: string | number | IUser): Object
  • Parameters

    • entityOrId: string | number | IUser

    Returns Object

    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);
      })();
    

getNewsletterEmails

  • getNewsletterEmails(): Promise<IResult<string>>
  • Returns Promise<IResult<string>>

    Server response and data with email addresses as plain text.

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): boolean
  • Parameters

    • user: IUser
    • roleId: string

    Returns boolean

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(...);
      })();
    

isDeviceUser

  • isDeviceUser(user: IUser): any
  • Parameters

    Returns any

list

  • list(filter?: object): Object
  • Parameters

    • Default value filter: object = {}

    Returns Object

    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);
      })();
    

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

  • update(entity: Partial<IUser>): Object
  • Parameters

    Returns Object

    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