File

projects/netgrif-components-core/src/lib/user/models/user.ts

Description

The user object that is used by the frontend in its logic.

Implements

IUser

Index

Properties
Methods
Accessors

Constructor

constructor(id: string, email: string, firstName: string, lastName: string, authorities: Array, roles: Array<ProcessRole>, groups?: Array, nextGroups?: Array, impersonated?: User)
Parameters :
Name Type Optional
id string No
email string No
firstName string No
lastName string No
authorities Array<string> No
roles Array<ProcessRole> No
groups Array<string> Yes
nextGroups Array<string> Yes
impersonated User Yes

Properties

Public authorities
Type : Array<string>
Public email
Type : string
Public firstName
Type : string
Public Optional groups
Type : Array<string>
Public id
Type : string
Public Optional impersonated
Type : User
Public lastName
Type : string
Public Optional nextGroups
Type : Array<string>
Public roles
Type : Array<ProcessRole>

Methods

Public getSelfOrImpersonated
getSelfOrImpersonated()
Returns : User

self if no impersonated user is present, or impersonated user otherwise

Public isEmpty
isEmpty()
Returns : boolean

true if the User object represents an empty user, false otherwise.

Public isImpersonating
isImpersonating()
Returns : boolean

true if user is impersonating another user

Accessors

fullName
getfullName()
name
getname()

Synonym for firstName.

Returns : string
surname
getsurname()

Synonym for lastName.

Returns : string
import {ProcessRole} from '../../resources/interface/process-role';
import {IUser} from './iuser';

/**
 * The user object that is used by the frontend in its logic.
 */
export class User implements IUser {

    constructor(
        public id: string,
        public email: string,
        public firstName: string,
        public lastName: string,
        public authorities: Array<string>,
        public roles: Array<ProcessRole>,
        public groups?: Array<string>,
        public nextGroups?: Array<string>,
        public impersonated?: User
    ) {
    }

    get fullName() {
        return this.firstName + ' ' + this.lastName;
    }

    /**
     * Synonym for `firstName`.
     */
    public get name(): string {
        return this.firstName;
    }

    /**
     * Synonym for `lastName`.
     */
    public get surname(): string {
        return this.lastName;
    }

    /**
     * @returns `true` if the User object represents an empty user, `false` otherwise.
     */
    public isEmpty(): boolean {
        return this.id === '';
    }

    /**
     * @returns self if no impersonated user is present, or impersonated user otherwise
     */
    public getSelfOrImpersonated(): User {
        return this.isImpersonating() ? this.impersonated : this;
    }

    /**
     * @returns true if user is impersonating another user
     */
    public isImpersonating(): boolean {
        return !!this.impersonated;
    }
}

result-matching ""

    No results matching ""