import { KeycloakProfile } from 'keycloak-js';
import { IIqserUser, IqserUser } from '@iqser/common-ui/lib/users';
import { List } from '@iqser/common-ui/lib/utils';

export class User extends IqserUser {
    readonly isManager = this.has('RED_MANAGER');
    readonly isUserAdmin = this.has('RED_USER_ADMIN');
    readonly isUser = this.has('RED_USER');
    readonly isAdmin = this.has('RED_ADMIN');

    constructor(user: KeycloakProfile | IIqserUser, readonly roles: List, readonly userId: string) {
        super(user, roles, userId);
        this.isSpecial = this.isManager;
    }
}
