UNPKG

5.81 kBJavaScriptView Raw
1var __extends = (this && this.__extends) || (function () {
2 var extendStatics = Object.setPrototypeOf ||
3 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5 return function (d, b) {
6 extendStatics(d, b);
7 function __() { this.constructor = d; }
8 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9 };
10})();
11/**
12 * @license Framing v0.8.11
13 * Copyright 2016-2017 Biznas Innovations, Inc. http://biznas.io
14 * License: Apache License, Version 2.0
15 */
16import { Framer, Framing } from '@framing/ng-core';
17import { Injectable, NgModule } from '@angular/core';
18var SecurityGuardAuthorizer = (function () {
19 function SecurityGuardAuthorizer() {
20 }
21 return SecurityGuardAuthorizer;
22}());
23var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
24 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
26 r = Reflect.decorate(decorators, target, key, desc);
27 else
28 for (var i = decorators.length - 1; i >= 0; i--)
29 if (d = decorators[i])
30 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31 return c > 3 && r && Object.defineProperty(target, key, r), r;
32};
33var __metadata = (undefined && undefined.__metadata) || function (k, v) {
34 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
35 return Reflect.metadata(k, v);
36};
37var SecurityGuardService = (function () {
38 function SecurityGuardService(authService) {
39 this.authService = authService;
40 }
41 /**
42 * CanActivate hook.
43 */
44 SecurityGuardService.prototype.canActivate = function (route, state) {
45 var model = route.data ? route.data.SecurityGuardModel : undefined;
46 if (model) {
47 return this.authService.canActivate(model, route, state);
48 }
49 else {
50 console.warn("Expecting 'SecurityGuardModel' in route data", { route: route });
51 return false;
52 }
53 };
54 /**
55 * CanActivateChild hook.
56 */
57 SecurityGuardService.prototype.canActivateChild = function (route, state) {
58 var model = route.data ? route.data.SecurityGuardModel : undefined;
59 if (model) {
60 return this.authService.canActivate(model, route, state);
61 }
62 else {
63 console.warn("Expecting 'SecurityGuardModel' in route data", { route: route });
64 return false;
65 }
66 };
67 /**
68 * CanActivate hook.
69 */
70 SecurityGuardService.prototype.canLoad = function (route) {
71 var model = route.data ? route.data.SecurityGuardModel : undefined;
72 if (model) {
73 return this.authService.canLoad(model, route);
74 }
75 else {
76 console.warn("Expecting 'SecurityGuardModel' in route data", { route: route });
77 return false;
78 }
79 };
80 return SecurityGuardService;
81}());
82SecurityGuardService = __decorate([
83 Injectable(),
84 __metadata("design:paramtypes", [SecurityGuardAuthorizer])
85], SecurityGuardService);
86var SecurityGuardFramer = (function (_super) {
87 __extends(SecurityGuardFramer, _super);
88 function SecurityGuardFramer() {
89 return _super !== null && _super.apply(this, arguments) || this;
90 }
91 Object.defineProperty(SecurityGuardFramer.prototype, "framerName", {
92 get: function () { return 'SecurityGuard'; },
93 enumerable: true,
94 configurable: true
95 });
96 Object.defineProperty(SecurityGuardFramer.prototype, "addModelToRouteData", {
97 get: function () { return true; },
98 enumerable: true,
99 configurable: true
100 });
101 Object.defineProperty(SecurityGuardFramer.prototype, "defaultModel", {
102 get: function () {
103 return {
104 authorization: undefined,
105 canActive: true,
106 canLoad: false,
107 canActivateChild: false,
108 };
109 },
110 enumerable: true,
111 configurable: true
112 });
113 /**
114 * The frame function.
115 */
116 SecurityGuardFramer.prototype.frame = function (framing) {
117 if (this.theModel.canActive) {
118 this.route.canActivate = [SecurityGuardService];
119 }
120 if (this.theModel.canActivateChild) {
121 this.route.canActivateChild = [SecurityGuardService];
122 }
123 if (this.theModel.canLoad) {
124 this.route.canLoad = [SecurityGuardService];
125 }
126 };
127 return SecurityGuardFramer;
128}(Framer));
129var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
130 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
131 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
132 r = Reflect.decorate(decorators, target, key, desc);
133 else
134 for (var i = decorators.length - 1; i >= 0; i--)
135 if (d = decorators[i])
136 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
137 return c > 3 && r && Object.defineProperty(target, key, r), r;
138};
139var SecurityGuardModule = (function () {
140 function SecurityGuardModule() {
141 }
142 return SecurityGuardModule;
143}());
144SecurityGuardModule = __decorate$1([
145 NgModule(Framing(function (framing) { return framing.provider(SecurityGuardService); }))
146], SecurityGuardModule);
147export { SecurityGuardAuthorizer, SecurityGuardFramer, SecurityGuardModule, SecurityGuardService };
148//# sourceMappingURL=ng-security.es5.js.map