UNPKG

@mvx/identity

Version:

identity is oidc for mvc, type-mvc is base on koa. Decorator, Ioc, AOP mvc framework on server.

33 lines (31 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RoleVaildate = void 0; const tslib_1 = require("tslib"); const ioc_1 = require("@tsdi/ioc"); const aop_1 = require("@tsdi/aop"); const mvc_1 = require("@mvx/mvc"); let RoleVaildate = class RoleVaildate { vaildate(ctx, authAnnotation, joinPoint) { if (ioc_1.isFunction(ctx.hasRole) && authAnnotation && authAnnotation.length) { if (!ctx.hasRole(...authAnnotation.map(a => a.role).filter(a => a))) { throw new mvc_1.ForbiddenError(); } } } static ρAnn() { return { "name": "RoleVaildate", "params": { "vaildate": ["ctx", "authAnnotation", "joinPoint"] } }; } }; tslib_1.__decorate([ aop_1.Before(mvc_1.AuthorizationPointcut, 'authAnnotation'), tslib_1.__param(0, ioc_1.Inject(mvc_1.ContextToken)), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object, Array, aop_1.Joinpoint]), tslib_1.__metadata("design:returntype", void 0) ], RoleVaildate.prototype, "vaildate", null); RoleVaildate = tslib_1.__decorate([ aop_1.Aspect() ], RoleVaildate); exports.RoleVaildate = RoleVaildate; //# sourceMappingURL=../sourcemaps/vaildates/RoleVaildate.js.map