UNPKG

@iredium/butterfly

Version:
52 lines (51 loc) 1.96 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.UserPolicy = void 0; var api_policy_1 = require("./api_policy"); var UserPolicy = /** @class */ (function (_super) { __extends(UserPolicy, _super); function UserPolicy() { return _super !== null && _super.apply(this, arguments) || this; } UserPolicy.prototype.me = function () { return !!this.user; }; UserPolicy.prototype.index = function () { return true; }; UserPolicy.prototype.authenticate = function () { return true; }; UserPolicy.prototype.jobs = function () { return this.allowedUser(); }; UserPolicy.prototype.setAsAdmin = function () { return this.user.root(); }; UserPolicy.prototype.changePassword = function () { return this.allowedUser(); }; UserPolicy.prototype.createBySocial = function () { return true; }; UserPolicy.prototype.allowedUser = function () { return this.user && ((String(this.user.uuid) === String(this.record.uuid)) || this.user.admin()); }; return UserPolicy; }(api_policy_1.ApiPolicy)); exports.UserPolicy = UserPolicy;