UNPKG

@iredium/butterfly

Version:
49 lines (48 loc) 1.76 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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var api_policy_1 = require("../../policies/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._id) === String(this.record._id)) || this.user.admin()); }; return UserPolicy; }(api_policy_1.ApiPolicy)); exports.UserPolicy = UserPolicy;