"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("../index");
var User = /** @class */ (function () {
    function User(name, roles, id, created) {
        if (name === void 0) { name = 'visitor'; }
        if (roles === void 0) { roles = ['ANONYMOUS']; }
        this.roles = [];
        this.permissions = index_1.PermissionsService.instance;
        this.name = name;
        this.roles = roles;
        if (!id) {
            this.id = index_1.Util.getUUID();
        }
        if (!created) {
            this.created = index_1.Util.getTimeStamp();
        }
    }
    User.prototype.addRole = function (role) {
        this.roles.push(role);
        this.roles = index_1.Util.arraySetUnique(this.roles);
    };
    User.prototype.removeRole = function (role) {
        var filtered = this.roles.filter(function (value, index, arr) {
            return value !== role;
        });
        this.roles = filtered;
        // this.roles = Util.arrayRemoveValue(this.roles, role);;
    };
    User.prototype.hasRole = function (role) {
        var bool = false;
        this.roles.forEach(function (roleName) {
            if (roleName === role)
                bool = true;
        });
        return bool;
        // return this.roles.includes(role);
    };
    return User;
}());
exports.User = User;
//# sourceMappingURL=user.js.map