import { Util, PermissionsService } from '../index';
export class User {
    constructor(name = 'visitor', roles = ['ANONYMOUS'], id, created) {
        this.roles = [];
        this.permissions = PermissionsService.instance;
        this.name = name;
        this.roles = roles;
        if (!id) {
            this.id = Util.getUUID();
        }
        if (!created) {
            this.created = Util.getTimeStamp();
        }
    }
    addRole(role) {
        this.roles.push(role);
        this.roles = Util.arraySetUnique(this.roles);
    }
    removeRole(role) {
        let filtered = this.roles.filter((value, index, arr) => {
            return value !== role;
        });
        this.roles = filtered;
        // this.roles = Util.arrayRemoveValue(this.roles, role);;
    }
    hasRole(role) {
        let bool = false;
        this.roles.forEach((roleName) => {
            if (roleName === role)
                bool = true;
        });
        return bool;
        // return this.roles.includes(role);
    }
}
//# sourceMappingURL=user.js.map