1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs'), require('@angular/material'), require('rxjs/operators'), require('@ngrx/store'), require('@soushians/shared'), require('@soushians/config'), require('@angular/material/snack-bar'), require('@angular/common'), require('@angular/router'), require('@angular/flex-layout'), require('@angular/platform-browser/animations'), require('@angular/forms'), require('@ngrx/effects'), require('@soushians/form'), require('rxjs/add/operator/do')) :
|
3 | typeof define === 'function' && define.amd ? define('@soushians/authentication', ['exports', '@angular/core', '@angular/common/http', 'rxjs', '@angular/material', 'rxjs/operators', '@ngrx/store', '@soushians/shared', '@soushians/config', '@angular/material/snack-bar', '@angular/common', '@angular/router', '@angular/flex-layout', '@angular/platform-browser/animations', '@angular/forms', '@ngrx/effects', '@soushians/form', 'rxjs/add/operator/do'], factory) :
|
4 | (global = global || self, factory((global.soushians = global.soushians || {}, global.soushians.authentication = {}), global.ng.core, global.ng.common.http, global.rxjs, global.ng.material, global.rxjs.operators, global.store, global.shared, global.config, global.ng.material['snack-bar'], global.ng.common, global.ng.router, global.ng['flex-layout'], global.ng.platformBrowser.animations, global.ng.forms, global.effects, global.form));
|
5 | }(this, function (exports, core, http, rxjs, material, operators, store, shared, config, snackBar, common, router, flexLayout, animations, forms, effects, form) { 'use strict';
|
6 |
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var extendStatics = function(d, b) {
|
24 | extendStatics = Object.setPrototypeOf ||
|
25 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
26 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
27 | return extendStatics(d, b);
|
28 | };
|
29 |
|
30 | function __extends(d, b) {
|
31 | extendStatics(d, b);
|
32 | function __() { this.constructor = d; }
|
33 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
34 | }
|
35 |
|
36 | var __assign = function() {
|
37 | __assign = Object.assign || function __assign(t) {
|
38 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
39 | s = arguments[i];
|
40 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
41 | }
|
42 | return t;
|
43 | };
|
44 | return __assign.apply(this, arguments);
|
45 | };
|
46 |
|
47 | function __rest(s, e) {
|
48 | var t = {};
|
49 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
50 | t[p] = s[p];
|
51 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
52 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
53 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
54 | t[p[i]] = s[p[i]];
|
55 | }
|
56 | return t;
|
57 | }
|
58 |
|
59 | function __decorate(decorators, target, key, desc) {
|
60 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
61 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
62 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
63 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
64 | }
|
65 |
|
66 | function __param(paramIndex, decorator) {
|
67 | return function (target, key) { decorator(target, key, paramIndex); }
|
68 | }
|
69 |
|
70 | function __metadata(metadataKey, metadataValue) {
|
71 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
72 | }
|
73 |
|
74 | function __awaiter(thisArg, _arguments, P, generator) {
|
75 | return new (P || (P = Promise))(function (resolve, reject) {
|
76 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
77 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
78 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
79 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
80 | });
|
81 | }
|
82 |
|
83 | function __generator(thisArg, body) {
|
84 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
85 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
86 | function verb(n) { return function (v) { return step([n, v]); }; }
|
87 | function step(op) {
|
88 | if (f) throw new TypeError("Generator is already executing.");
|
89 | while (_) try {
|
90 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
91 | if (y = 0, t) op = [op[0] & 2, t.value];
|
92 | switch (op[0]) {
|
93 | case 0: case 1: t = op; break;
|
94 | case 4: _.label++; return { value: op[1], done: false };
|
95 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
96 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
97 | default:
|
98 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
99 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
100 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
101 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
102 | if (t[2]) _.ops.pop();
|
103 | _.trys.pop(); continue;
|
104 | }
|
105 | op = body.call(thisArg, _);
|
106 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
107 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
108 | }
|
109 | }
|
110 |
|
111 | function __exportStar(m, exports) {
|
112 | for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
113 | }
|
114 |
|
115 | function __values(o) {
|
116 | var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
117 | if (m) return m.call(o);
|
118 | return {
|
119 | next: function () {
|
120 | if (o && i >= o.length) o = void 0;
|
121 | return { value: o && o[i++], done: !o };
|
122 | }
|
123 | };
|
124 | }
|
125 |
|
126 | function __read(o, n) {
|
127 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
128 | if (!m) return o;
|
129 | var i = m.call(o), r, ar = [], e;
|
130 | try {
|
131 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
132 | }
|
133 | catch (error) { e = { error: error }; }
|
134 | finally {
|
135 | try {
|
136 | if (r && !r.done && (m = i["return"])) m.call(i);
|
137 | }
|
138 | finally { if (e) throw e.error; }
|
139 | }
|
140 | return ar;
|
141 | }
|
142 |
|
143 | function __spread() {
|
144 | for (var ar = [], i = 0; i < arguments.length; i++)
|
145 | ar = ar.concat(__read(arguments[i]));
|
146 | return ar;
|
147 | }
|
148 |
|
149 | function __spreadArrays() {
|
150 | for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
151 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
152 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
153 | r[k] = a[j];
|
154 | return r;
|
155 | };
|
156 |
|
157 | function __await(v) {
|
158 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
159 | }
|
160 |
|
161 | function __asyncGenerator(thisArg, _arguments, generator) {
|
162 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
163 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
164 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
165 | function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
166 | function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
167 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
168 | function fulfill(value) { resume("next", value); }
|
169 | function reject(value) { resume("throw", value); }
|
170 | function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
171 | }
|
172 |
|
173 | function __asyncDelegator(o) {
|
174 | var i, p;
|
175 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
176 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
177 | }
|
178 |
|
179 | function __asyncValues(o) {
|
180 | if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
181 | var m = o[Symbol.asyncIterator], i;
|
182 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
183 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
184 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
185 | }
|
186 |
|
187 | function __makeTemplateObject(cooked, raw) {
|
188 | if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
189 | return cooked;
|
190 | };
|
191 |
|
192 | function __importStar(mod) {
|
193 | if (mod && mod.__esModule) return mod;
|
194 | var result = {};
|
195 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
196 | result.default = mod;
|
197 | return result;
|
198 | }
|
199 |
|
200 | function __importDefault(mod) {
|
201 | return (mod && mod.__esModule) ? mod : { default: mod };
|
202 | }
|
203 |
|
204 | |
205 |
|
206 |
|
207 |
|
208 | var UserModel = (function () {
|
209 | function UserModel(params) {
|
210 | var _this = this;
|
211 |
|
212 |
|
213 |
|
214 |
|
215 | this.Roles = [];
|
216 | params &&
|
217 | Object.keys(params).forEach(( |
218 |
|
219 |
|
220 |
|
221 | function (key) {
|
222 | if (key in params)
|
223 | (( (_this)))[key] = params[key];
|
224 | }));
|
225 | }
|
226 | return UserModel;
|
227 | }());
|
228 | if (false) {
|
229 |
|
230 | UserModel.prototype._id;
|
231 |
|
232 | UserModel.prototype.Username;
|
233 |
|
234 | UserModel.prototype.Email;
|
235 |
|
236 | UserModel.prototype.Roles;
|
237 | }
|
238 |
|
239 | |
240 |
|
241 |
|
242 |
|
243 |
|
244 | var SignInActionTypes = {
|
245 | WHO_AM_I: "[AUTHENTICATION] who am i",
|
246 | SIGNUP: "[AUTHENTICATION][SIGNUP] start",
|
247 | SIGNUP_SUCCEED: "[AUTHENTICATION][SIGNUP] Success",
|
248 | SIGNUP_FAILURE: "[AUTHENTICATION][SIGNUP] Failure",
|
249 | SIGNIN: "[AUTHENTICATION] Signin",
|
250 | DO_SIGNOUT: "[AUTHENTICATION] Do Signout",
|
251 | SIGNOUT: "[AUTHENTICATION] Signout",
|
252 | SIGNIN_SUCCEED: "[AUTHENTICATION][Signin] Success",
|
253 | SIGNIN_FAILURE: "[AUTHENTICATION][Signin] Failure",
|
254 | SIGNIN_REDIRECT: "[AUTHENTICATION][Signin] Redirect",
|
255 | SIGNIN_REQUIRED: "[AUTHENTICATION][Signin] Required",
|
256 | };
|
257 | var WhoAmIAction = (function () {
|
258 | function WhoAmIAction() {
|
259 | this.type = SignInActionTypes.WHO_AM_I;
|
260 | }
|
261 | return WhoAmIAction;
|
262 | }());
|
263 | if (false) {
|
264 |
|
265 | WhoAmIAction.prototype.type;
|
266 | }
|
267 | |
268 |
|
269 |
|
270 | var |
271 |
|
272 |
|
273 | Signup = (function () {
|
274 | function Signup(payload) {
|
275 | this.payload = payload;
|
276 | this.type = SignInActionTypes.SIGNUP;
|
277 | }
|
278 | return Signup;
|
279 | }());
|
280 | if (false) {
|
281 |
|
282 | Signup.prototype.type;
|
283 |
|
284 | Signup.prototype.payload;
|
285 | }
|
286 | var SignupSecceed = (function () {
|
287 | function SignupSecceed(payload) {
|
288 | this.payload = payload;
|
289 | this.type = SignInActionTypes.SIGNUP_SUCCEED;
|
290 | }
|
291 | return SignupSecceed;
|
292 | }());
|
293 | if (false) {
|
294 |
|
295 | SignupSecceed.prototype.type;
|
296 |
|
297 | SignupSecceed.prototype.payload;
|
298 | }
|
299 | var SignupFailed = (function () {
|
300 | function SignupFailed(payload) {
|
301 | this.payload = payload;
|
302 | this.type = SignInActionTypes.SIGNUP_FAILURE;
|
303 | }
|
304 | return SignupFailed;
|
305 | }());
|
306 | if (false) {
|
307 |
|
308 | SignupFailed.prototype.type;
|
309 |
|
310 | SignupFailed.prototype.payload;
|
311 | }
|
312 | |
313 |
|
314 |
|
315 | var |
316 |
|
317 |
|
318 | Signin = (function () {
|
319 | function Signin(payload) {
|
320 | this.payload = payload;
|
321 | this.type = SignInActionTypes.SIGNIN;
|
322 | }
|
323 | return Signin;
|
324 | }());
|
325 | if (false) {
|
326 |
|
327 | Signin.prototype.type;
|
328 |
|
329 | Signin.prototype.payload;
|
330 | }
|
331 | var SigninSecceed = (function () {
|
332 | function SigninSecceed(payload) {
|
333 | this.payload = payload;
|
334 | this.type = SignInActionTypes.SIGNIN_SUCCEED;
|
335 | }
|
336 | return SigninSecceed;
|
337 | }());
|
338 | if (false) {
|
339 |
|
340 | SigninSecceed.prototype.type;
|
341 |
|
342 | SigninSecceed.prototype.payload;
|
343 | }
|
344 | var SigninFailed = (function () {
|
345 | function SigninFailed(payload) {
|
346 | this.payload = payload;
|
347 | this.type = SignInActionTypes.SIGNIN_FAILURE;
|
348 | }
|
349 | return SigninFailed;
|
350 | }());
|
351 | if (false) {
|
352 |
|
353 | SigninFailed.prototype.type;
|
354 |
|
355 | SigninFailed.prototype.payload;
|
356 | }
|
357 | var SigninRedirect = (function () {
|
358 | function SigninRedirect() {
|
359 | this.type = SignInActionTypes.SIGNIN_REDIRECT;
|
360 | }
|
361 | return SigninRedirect;
|
362 | }());
|
363 | if (false) {
|
364 |
|
365 | SigninRedirect.prototype.type;
|
366 | }
|
367 | var DoSignoutAction = (function () {
|
368 | function DoSignoutAction() {
|
369 | this.type = SignInActionTypes.DO_SIGNOUT;
|
370 | }
|
371 | return DoSignoutAction;
|
372 | }());
|
373 | if (false) {
|
374 |
|
375 | DoSignoutAction.prototype.type;
|
376 | }
|
377 | var SignoutAction = (function () {
|
378 | function SignoutAction() {
|
379 | this.type = SignInActionTypes.SIGNOUT;
|
380 | }
|
381 | return SignoutAction;
|
382 | }());
|
383 | if (false) {
|
384 |
|
385 | SignoutAction.prototype.type;
|
386 | }
|
387 | var SigninRequiredAction = (function () {
|
388 | function SigninRequiredAction() {
|
389 | this.type = SignInActionTypes.SIGNIN_REQUIRED;
|
390 | }
|
391 | return SigninRequiredAction;
|
392 | }());
|
393 | if (false) {
|
394 |
|
395 | SigninRequiredAction.prototype.type;
|
396 | }
|
397 |
|
398 | |
399 |
|
400 |
|
401 |
|
402 | |
403 |
|
404 |
|
405 | function AuthenticationModuleConfig() { }
|
406 | if (false) {
|
407 |
|
408 | AuthenticationModuleConfig.prototype.mode;
|
409 |
|
410 | AuthenticationModuleConfig.prototype.token;
|
411 |
|
412 | AuthenticationModuleConfig.prototype.server;
|
413 |
|
414 | AuthenticationModuleConfig.prototype.endpoints;
|
415 |
|
416 | AuthenticationModuleConfig.prototype.forms;
|
417 |
|
418 | AuthenticationModuleConfig.prototype.env;
|
419 |
|
420 | AuthenticationModuleConfig.prototype.afterSignoutRedirectTo;
|
421 |
|
422 | AuthenticationModuleConfig.prototype.signupValidator;
|
423 |
|
424 | AuthenticationModuleConfig.prototype.afterSignin;
|
425 |
|
426 | AuthenticationModuleConfig.prototype.responseToUser;
|
427 | }
|
428 | var ɵ0 = |
429 |
|
430 |
|
431 |
|
432 | function (value) { return rxjs.of(true); }, ɵ1 = |
433 |
|
434 |
|
435 |
|
436 | function (user) { }, ɵ2 = |
437 |
|
438 |
|
439 |
|
440 | function (user) { return user; };
|
441 |
|
442 | var MODULE_DEFAULT_CONFIG = {
|
443 | mode: "cookie-base",
|
444 | token: {
|
445 | time: 24 * 12 * 60 * 60
|
446 | },
|
447 | server: "frontend_server",
|
448 | endpoints: {
|
449 | signOut: "",
|
450 | signOutMethod: "get",
|
451 | signIn: "",
|
452 | signUp: "",
|
453 | whoAmI: ""
|
454 | },
|
455 | forms: {
|
456 | signIn: "",
|
457 | signUp: ""
|
458 | },
|
459 | env: {
|
460 | production: false,
|
461 | frontend_server: "auth/module/frontend_server/did/not/set",
|
462 | server: "auth/module/server/did/not/set"
|
463 | },
|
464 | afterSignoutRedirectTo: "/",
|
465 | signupValidator: (ɵ0),
|
466 | afterSignin: (ɵ1),
|
467 | responseToUser: (ɵ2)
|
468 | };
|
469 |
|
470 | var MODULE_CONFIG_TOKEN = new core.InjectionToken("ModuleConfig");
|
471 |
|
472 | |
473 |
|
474 |
|
475 |
|
476 | var AuthenticationConfigurationService = (function () {
|
477 | function AuthenticationConfigurationService(configFile, store) {
|
478 | var _this = this;
|
479 | this.store = store;
|
480 | this.config$ = new rxjs.BehaviorSubject(this._config);
|
481 | this._config = Object.assign({}, MODULE_DEFAULT_CONFIG, configFile);
|
482 | this.config$.next(this._config);
|
483 | this.store.select(config.getAuthenticationModuleConfig).subscribe(( |
484 |
|
485 |
|
486 |
|
487 | function (storeConfig) {
|
488 | if (!storeConfig)
|
489 | return;
|
490 | _this._config = Object.assign({}, _this._config, storeConfig.Config);
|
491 | _this.config$.next(_this._config);
|
492 | }));
|
493 | }
|
494 | Object.defineProperty(AuthenticationConfigurationService.prototype, "config", {
|
495 | get: /**
|
496 | * @return {?}
|
497 | */
|
498 | function () {
|
499 | return this._config;
|
500 | },
|
501 | enumerable: true,
|
502 | configurable: true
|
503 | });
|
504 | AuthenticationConfigurationService.decorators = [
|
505 | { type: core.Injectable, args: [{
|
506 | providedIn: "root"
|
507 | },] }
|
508 | ];
|
509 |
|
510 | AuthenticationConfigurationService.ctorParameters = function () { return [
|
511 | { type: undefined, decorators: [{ type: core.Inject, args: [MODULE_CONFIG_TOKEN,] }] },
|
512 | { type: store.Store }
|
513 | ]; };
|
514 | AuthenticationConfigurationService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function AuthenticationConfigurationService_Factory() { return new AuthenticationConfigurationService(core.ɵɵinject(MODULE_CONFIG_TOKEN), core.ɵɵinject(store.Store)); }, token: AuthenticationConfigurationService, providedIn: "root" });
|
515 | return AuthenticationConfigurationService;
|
516 | }());
|
517 | if (false) {
|
518 | |
519 |
|
520 |
|
521 |
|
522 | AuthenticationConfigurationService.prototype._config;
|
523 |
|
524 | AuthenticationConfigurationService.prototype.config$;
|
525 | |
526 |
|
527 |
|
528 |
|
529 | AuthenticationConfigurationService.prototype.store;
|
530 | }
|
531 |
|
532 | |
533 |
|
534 |
|
535 |
|
536 |
|
537 | var AuthenticationActionTypes = {
|
538 | PROGRESSING_STARTED: '[AUTHENTICATION] PROGRESSING_STARTED',
|
539 | PROGRESSING_FINISHED: '[AUTHENTICATION] PROGRESSING_FINISHED',
|
540 | FAILED_HAPPENED: '[AUTHENTICATION] FAILED_HAPPENED',
|
541 | };
|
542 | var ProgressingStarted = (function () {
|
543 | function ProgressingStarted() {
|
544 | this.type = "[AUTHENTICATION] PROGRESSING_STARTED" ;
|
545 | }
|
546 | return ProgressingStarted;
|
547 | }());
|
548 | if (false) {
|
549 |
|
550 | ProgressingStarted.prototype.type;
|
551 | }
|
552 | var ProgressingFinished = (function () {
|
553 | function ProgressingFinished() {
|
554 | this.type = "[AUTHENTICATION] PROGRESSING_FINISHED" ;
|
555 | }
|
556 | return ProgressingFinished;
|
557 | }());
|
558 | if (false) {
|
559 |
|
560 | ProgressingFinished.prototype.type;
|
561 | }
|
562 | var FailedHappened = (function () {
|
563 | function FailedHappened(payload) {
|
564 | this.payload = payload;
|
565 | this.type = "[AUTHENTICATION] FAILED_HAPPENED" ;
|
566 | }
|
567 | return FailedHappened;
|
568 | }());
|
569 | if (false) {
|
570 |
|
571 | FailedHappened.prototype.type;
|
572 |
|
573 | FailedHappened.prototype.payload;
|
574 | }
|
575 |
|
576 | |
577 |
|
578 |
|
579 |
|
580 |
|
581 | var NEW_CAPTCHA = '[captcha] new captcha';
|
582 |
|
583 | var TOKEN_REQUESTED = '[captcha] token_requested';
|
584 |
|
585 | var TOKEN_RECEIVED = '[captcha] token_received';
|
586 |
|
587 | var CAPTCHA_IMAGE_REQUESTED = '[captcha] captcha_image_requested';
|
588 |
|
589 | var CAPTCHA_IMAGE_LOADED = '[captcha] captcha_image_loaded';
|
590 |
|
591 | var CAPTCHA_ENTERED = '[captcha] CAPTCHA_ENTERED';
|
592 |
|
593 | var CLEAR_CAPTCHA = '[captcha] CLEAR_CAPTCHA';
|
594 | var NewCaptcha = (function () {
|
595 | function NewCaptcha() {
|
596 | this.type = NEW_CAPTCHA;
|
597 | }
|
598 | return NewCaptcha;
|
599 | }());
|
600 | if (false) {
|
601 |
|
602 | NewCaptcha.prototype.type;
|
603 | }
|
604 | var TokenRequested = (function () {
|
605 | function TokenRequested() {
|
606 | this.type = TOKEN_REQUESTED;
|
607 | }
|
608 | return TokenRequested;
|
609 | }());
|
610 | if (false) {
|
611 |
|
612 | TokenRequested.prototype.type;
|
613 | }
|
614 | var TokenReceived = (function () {
|
615 | function TokenReceived(payload) {
|
616 | this.payload = payload;
|
617 | this.type = TOKEN_RECEIVED;
|
618 | }
|
619 | return TokenReceived;
|
620 | }());
|
621 | if (false) {
|
622 |
|
623 | TokenReceived.prototype.type;
|
624 |
|
625 | TokenReceived.prototype.payload;
|
626 | }
|
627 | var CaptchaImageRequested = (function () {
|
628 | function CaptchaImageRequested() {
|
629 | this.type = CAPTCHA_IMAGE_REQUESTED;
|
630 | }
|
631 | return CaptchaImageRequested;
|
632 | }());
|
633 | if (false) {
|
634 |
|
635 | CaptchaImageRequested.prototype.type;
|
636 | }
|
637 | var CaptchaImageLoaded = (function () {
|
638 | function CaptchaImageLoaded() {
|
639 | this.type = CAPTCHA_IMAGE_LOADED;
|
640 | }
|
641 | return CaptchaImageLoaded;
|
642 | }());
|
643 | if (false) {
|
644 |
|
645 | CaptchaImageLoaded.prototype.type;
|
646 | }
|
647 | var CaptchaEntered = (function () {
|
648 | function CaptchaEntered(payload) {
|
649 | this.payload = payload;
|
650 | this.type = CAPTCHA_ENTERED;
|
651 | }
|
652 | return CaptchaEntered;
|
653 | }());
|
654 | if (false) {
|
655 |
|
656 | CaptchaEntered.prototype.type;
|
657 |
|
658 | CaptchaEntered.prototype.payload;
|
659 | }
|
660 | var ClearCaptcha = (function () {
|
661 | function ClearCaptcha() {
|
662 | this.type = CLEAR_CAPTCHA;
|
663 | }
|
664 | return ClearCaptcha;
|
665 | }());
|
666 | if (false) {
|
667 |
|
668 | ClearCaptcha.prototype.type;
|
669 | }
|
670 |
|
671 | |
672 |
|
673 |
|
674 |
|
675 |
|
676 | |
677 |
|
678 |
|
679 |
|
680 |
|
681 | var COOKIE_NAME = "ngs-authentication";
|
682 | var SigninService = (function () {
|
683 | function SigninService(http, store, configurationService, snackBar) {
|
684 | var _this = this;
|
685 | this.http = http;
|
686 | this.store = store;
|
687 | this.configurationService = configurationService;
|
688 | this.snackBar = snackBar;
|
689 | setTimeout(( |
690 |
|
691 |
|
692 | function () { return _this.store.dispatch(new WhoAmIAction()); }), 300);
|
693 | }
|
694 | |
695 |
|
696 |
|
697 |
|
698 | SigninService.prototype.signup = |
699 |
|
700 |
|
701 |
|
702 | function (model) {
|
703 | var _this = this;
|
704 | return this.configurationService.config$.pipe(operators.filter(( |
705 |
|
706 |
|
707 |
|
708 | function (config) { return config.endpoints.signUp != ""; })), operators.take(1), operators.switchMap(( |
709 |
|
710 |
|
711 |
|
712 | function (config) {
|
713 | return _this.http.post(config.env[config.server] + config.endpoints.signUp, model);
|
714 | })), operators.map(( |
715 |
|
716 |
|
717 |
|
718 | function (response) {
|
719 |
|
720 | var user = Object.assign({}, response.Result);
|
721 | if (user.Role) {
|
722 | user.Roles = [user.Role];
|
723 | }
|
724 | return user;
|
725 | })));
|
726 | };
|
727 | |
728 |
|
729 |
|
730 |
|
731 | SigninService.prototype.signin = |
732 |
|
733 |
|
734 |
|
735 | function (model) {
|
736 | var _this = this;
|
737 | return this.configurationService.config$.pipe(operators.filter(( |
738 |
|
739 |
|
740 |
|
741 | function (config) { return config.endpoints.signIn != ""; })), operators.take(1), operators.switchMap(( |
742 |
|
743 |
|
744 |
|
745 | function (config) { return _this.http.post(config.env[config.server] + config.endpoints.signIn, model); })), operators.map(this.configurationService.config.responseToUser), operators.map(( |
746 |
|
747 |
|
748 |
|
749 | function (user) {
|
750 | if (user.Role) {
|
751 | user.Roles = [user.Role];
|
752 | }
|
753 | return user;
|
754 | })), operators.tap(( |
755 |
|
756 |
|
757 |
|
758 | function (user) {
|
759 | if (_this.configurationService.config.mode == "token-base")
|
760 | shared.Cookie.setCookie(COOKIE_NAME, JSON.stringify(user), _this.configurationService.config.token.time);
|
761 | })), operators.tap(( |
762 |
|
763 |
|
764 |
|
765 | function (user) { return _this.configurationService.config.afterSignin(user); })));
|
766 | };
|
767 |
|
768 |
|
769 | |
770 |
|
771 |
|
772 | SigninService.prototype.signout =
|
773 |
|
774 | |
775 |
|
776 |
|
777 | function () {
|
778 |
|
779 | var config = this.configurationService.config;
|
780 |
|
781 | var tokenObject = JSON.parse(shared.Cookie.getCookie(COOKIE_NAME));
|
782 |
|
783 | var endpoint = shared.stringTemplate(config.env[config.server] + config.endpoints.signOut, tokenObject);
|
784 |
|
785 | var method = config.endpoints.signOutMethod || "get";
|
786 | if (["get", "put", "post", "patch", "delete"].indexOf(method) === -1) {
|
787 | rxjs.throwError(method + " is not valid http method. [ @starter/authentication/signinservice/singout ]");
|
788 | }
|
789 | return this.http[method](endpoint).pipe(operators.tap(( |
790 |
|
791 |
|
792 | function () {
|
793 | shared.Cookie.deleteCookie(COOKIE_NAME);
|
794 | })));
|
795 | };
|
796 | |
797 |
|
798 |
|
799 | SigninService.prototype.whoAmI = |
800 |
|
801 |
|
802 | function () {
|
803 | var _this = this;
|
804 | debugger;
|
805 |
|
806 | var user = { Token: "--" };
|
807 | if (this.configurationService.config.mode == "token-base") {
|
808 | try {
|
809 | user = JSON.parse(shared.Cookie.getCookie(COOKIE_NAME));
|
810 | }
|
811 | catch (error) { }
|
812 | }
|
813 | return this.configurationService.config$.pipe(operators.filter(( |
814 |
|
815 |
|
816 |
|
817 | function (config) { return config.endpoints.whoAmI != ""; })), operators.take(1), operators.switchMap(( |
818 |
|
819 |
|
820 |
|
821 | function (config) {
|
822 | return _this.http.get(shared.stringTemplate(config.env[config.server] + config.endpoints.whoAmI, { user: user }));
|
823 | })));
|
824 | };
|
825 | SigninService.decorators = [
|
826 | { type: core.Injectable, args: [{
|
827 | providedIn: "root"
|
828 | },] }
|
829 | ];
|
830 |
|
831 | SigninService.ctorParameters = function () { return [
|
832 | { type: http.HttpClient },
|
833 | { type: store.Store },
|
834 | { type: AuthenticationConfigurationService },
|
835 | { type: material.MatSnackBar }
|
836 | ]; };
|
837 | SigninService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function SigninService_Factory() { return new SigninService(core.ɵɵinject(http.HttpClient), core.ɵɵinject(store.Store), core.ɵɵinject(AuthenticationConfigurationService), core.ɵɵinject(snackBar.MatSnackBar)); }, token: SigninService, providedIn: "root" });
|
838 | return SigninService;
|
839 | }());
|
840 | if (false) {
|
841 | |
842 |
|
843 |
|
844 |
|
845 | SigninService.prototype.http;
|
846 | |
847 |
|
848 |
|
849 |
|
850 | SigninService.prototype.store;
|
851 | |
852 |
|
853 |
|
854 |
|
855 | SigninService.prototype.configurationService;
|
856 | |
857 |
|
858 |
|
859 |
|
860 | SigninService.prototype.snackBar;
|
861 | }
|
862 |
|
863 | |
864 |
|
865 |
|
866 |
|
867 | var SigninContainerComponent = (function () {
|
868 | function SigninContainerComponent(configurationService, store) {
|
869 | this.configurationService = configurationService;
|
870 | this.store = store;
|
871 | this.signedIn$ = new core.EventEmitter();
|
872 | this.formId$ = this.configurationService.config$.map(( |
873 |
|
874 |
|
875 |
|
876 | function (config) { return config.forms.signIn; }));
|
877 | }
|
878 | |
879 |
|
880 |
|
881 |
|
882 | SigninContainerComponent.prototype.signIn = |
883 |
|
884 |
|
885 |
|
886 | function (formValue) {
|
887 | this.store.dispatch(new Signin(formValue));
|
888 | this.signedIn$.emit(true);
|
889 | };
|
890 | SigninContainerComponent.decorators = [
|
891 | { type: core.Component, args: [{
|
892 | template: "\n <auth-signin \n [formId]='(formId$ | async)'\n (signedin)=\"signIn($event)\"\n ></auth-signin>\n "
|
893 | }] }
|
894 | ];
|
895 |
|
896 | SigninContainerComponent.ctorParameters = function () { return [
|
897 | { type: AuthenticationConfigurationService },
|
898 | { type: store.Store }
|
899 | ]; };
|
900 | SigninContainerComponent.propDecorators = {
|
901 | signedIn$: [{ type: core.Output }]
|
902 | };
|
903 | return SigninContainerComponent;
|
904 | }());
|
905 | if (false) {
|
906 |
|
907 | SigninContainerComponent.prototype.formId$;
|
908 |
|
909 | SigninContainerComponent.prototype.signedIn$;
|
910 | |
911 |
|
912 |
|
913 |
|
914 | SigninContainerComponent.prototype.configurationService;
|
915 | |
916 |
|
917 |
|
918 |
|
919 | SigninContainerComponent.prototype.store;
|
920 | }
|
921 |
|
922 | |
923 |
|
924 |
|
925 |
|
926 | var AuthenticationContainerComponent = (function () {
|
927 | function AuthenticationContainerComponent() {
|
928 | }
|
929 | AuthenticationContainerComponent.decorators = [
|
930 | { type: core.Component, args: [{
|
931 | template: "\n <router-outlet></router-outlet>\n "
|
932 | }] }
|
933 | ];
|
934 | return AuthenticationContainerComponent;
|
935 | }());
|
936 |
|
937 | |
938 |
|
939 |
|
940 |
|
941 | var SignupContainerComponent = (function () {
|
942 | function SignupContainerComponent(configurationService, store, snackBar) {
|
943 | this.configurationService = configurationService;
|
944 | this.store = store;
|
945 | this.snackBar = snackBar;
|
946 | this.signedUp$ = new core.EventEmitter();
|
947 | this.formId$ = this.configurationService.config$.map(( |
948 |
|
949 |
|
950 |
|
951 | function (config) { return config.forms.signUp; }));
|
952 | }
|
953 | |
954 |
|
955 |
|
956 |
|
957 | SignupContainerComponent.prototype.signup = |
958 |
|
959 |
|
960 |
|
961 | function (formValue) {
|
962 | var _this = this;
|
963 | this.configurationService.config$
|
964 | .pipe(operators.take(1), operators.switchMap(( |
965 |
|
966 |
|
967 |
|
968 | function (config) { return config.signupValidator(formValue); })))
|
969 | .subscribe(( |
970 |
|
971 |
|
972 |
|
973 | function (validation) {
|
974 | if (validation) {
|
975 | _this.store.dispatch(new Signup(formValue));
|
976 | _this.signedUp$.emit(true);
|
977 | }
|
978 | else {
|
979 | _this.snackBar.open("رمز عبور یکسان نیست", null, {
|
980 | duration: 2222
|
981 | });
|
982 | }
|
983 | }));
|
984 | };
|
985 | SignupContainerComponent.decorators = [
|
986 | { type: core.Component, args: [{
|
987 | template: "\n <auth-signup \n [formId]='(formId$ | async)'\n (signedup)=\"signup($event)\"\n ></auth-signup>\n "
|
988 | }] }
|
989 | ];
|
990 |
|
991 | SignupContainerComponent.ctorParameters = function () { return [
|
992 | { type: AuthenticationConfigurationService },
|
993 | { type: store.Store },
|
994 | { type: material.MatSnackBar }
|
995 | ]; };
|
996 | SignupContainerComponent.propDecorators = {
|
997 | signedUp$: [{ type: core.Output }]
|
998 | };
|
999 | return SignupContainerComponent;
|
1000 | }());
|
1001 | if (false) {
|
1002 |
|
1003 | SignupContainerComponent.prototype.formId$;
|
1004 |
|
1005 | SignupContainerComponent.prototype.signedUp$;
|
1006 | |
1007 |
|
1008 |
|
1009 |
|
1010 | SignupContainerComponent.prototype.configurationService;
|
1011 | |
1012 |
|
1013 |
|
1014 |
|
1015 | SignupContainerComponent.prototype.store;
|
1016 | |
1017 |
|
1018 |
|
1019 |
|
1020 | SignupContainerComponent.prototype.snackBar;
|
1021 | }
|
1022 |
|
1023 | |
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 | var routes = [
|
1029 | {
|
1030 | path: "auth",
|
1031 | component: AuthenticationContainerComponent,
|
1032 | children: [
|
1033 | {
|
1034 | path: "signin",
|
1035 |
|
1036 | component: SigninContainerComponent
|
1037 | },
|
1038 | {
|
1039 | path: "signup",
|
1040 |
|
1041 | component: SignupContainerComponent
|
1042 | }
|
1043 | ]
|
1044 | }
|
1045 | ];
|
1046 |
|
1047 | var AuthenticationRoutingModule = router.RouterModule.forChild(routes);
|
1048 |
|
1049 | |
1050 |
|
1051 |
|
1052 |
|
1053 | var SigninComponent = (function () {
|
1054 | function SigninComponent() {
|
1055 | this.signedin = new core.EventEmitter();
|
1056 | }
|
1057 | |
1058 |
|
1059 |
|
1060 |
|
1061 | SigninComponent.prototype.signin = |
1062 |
|
1063 |
|
1064 |
|
1065 | function (formGroup) {
|
1066 | if (!formGroup.valid)
|
1067 | return;
|
1068 | this.signedin.emit(formGroup.value);
|
1069 | };
|
1070 | SigninComponent.decorators = [
|
1071 | { type: core.Component, args: [{
|
1072 | selector: "auth-signin",
|
1073 | template: "<div fxLayout='row' fxLayoutAlign=\"center center\">\r\n <ngs-form-view \r\n [id]=\"formId\"\r\n [card]=\"true\"\r\n (accept)=\"signin($event)\"\r\n ></ngs-form-view>\r\n</div>\r\n<!-- <div>\r\n <a fxFlex=\"nogrow\" routerLink=\"/user/password/reset\" mat-raised-button fxFlexFill>\u06A9\u0644\u0645\u0647 \u0639\u0628\u0648\u0631 \u062E\u0648\u062F \u0631\u0627 \u0641\u0631\u0627\u0645\u0648\u0634 \u06A9\u0631\u062F\u0647 \u0627\u06CC\u062F\u061F</a>\r\n</div> -->",
|
1074 | styles: [""]
|
1075 | }] }
|
1076 | ];
|
1077 |
|
1078 | SigninComponent.ctorParameters = function () { return []; };
|
1079 | SigninComponent.propDecorators = {
|
1080 | signedin: [{ type: core.Output }],
|
1081 | formId: [{ type: core.Input }]
|
1082 | };
|
1083 | return SigninComponent;
|
1084 | }());
|
1085 | if (false) {
|
1086 |
|
1087 | SigninComponent.prototype.signedin;
|
1088 |
|
1089 | SigninComponent.prototype.formId;
|
1090 | }
|
1091 |
|
1092 | |
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 | var WithCredentialInterceptor = (function () {
|
1098 | function WithCredentialInterceptor(configurationService) {
|
1099 | this.configurationService = configurationService;
|
1100 | }
|
1101 | |
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 | WithCredentialInterceptor.prototype.intercept = |
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | function (request, next) {
|
1112 |
|
1113 | (( (request))).withCredentials = true;
|
1114 | return next.handle(request);
|
1115 | };
|
1116 | WithCredentialInterceptor.decorators = [
|
1117 | { type: core.Injectable }
|
1118 | ];
|
1119 |
|
1120 | WithCredentialInterceptor.ctorParameters = function () { return [
|
1121 | { type: AuthenticationConfigurationService }
|
1122 | ]; };
|
1123 | return WithCredentialInterceptor;
|
1124 | }());
|
1125 | if (false) {
|
1126 | |
1127 |
|
1128 |
|
1129 |
|
1130 | WithCredentialInterceptor.prototype.configurationService;
|
1131 | }
|
1132 |
|
1133 | |
1134 |
|
1135 |
|
1136 |
|
1137 | var UnauthorizedInterceptor = (function () {
|
1138 | function UnauthorizedInterceptor(router, store // private signinService: SigninService
|
1139 | ) {
|
1140 | this.router = router;
|
1141 | this.store = store;
|
1142 | }
|
1143 | |
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 | UnauthorizedInterceptor.prototype.intercept = |
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 | function (request, next) {
|
1154 | var _this = this;
|
1155 | return next
|
1156 | .handle(request)
|
1157 | .map(( |
1158 |
|
1159 |
|
1160 |
|
1161 | function (event) {
|
1162 | if (event instanceof http.HttpResponse)
|
1163 | return event;
|
1164 | }))
|
1165 | .catch(( |
1166 |
|
1167 |
|
1168 |
|
1169 | function (err) {
|
1170 | if (!(err instanceof http.HttpErrorResponse))
|
1171 | return rxjs.throwError(err);
|
1172 | if (err.status != 401)
|
1173 | return rxjs.throwError(err);
|
1174 | if (err.url.includes("logout"))
|
1175 | return rxjs.throwError(err);
|
1176 | if (err.url.includes("user/account/profile"))
|
1177 | return rxjs.throwError(err);
|
1178 | _this.store.dispatch(new SignoutAction());
|
1179 | return rxjs.throwError("Unauthorized");
|
1180 | }));
|
1181 | };
|
1182 | UnauthorizedInterceptor.decorators = [
|
1183 | { type: core.Injectable }
|
1184 | ];
|
1185 |
|
1186 | UnauthorizedInterceptor.ctorParameters = function () { return [
|
1187 | { type: router.Router },
|
1188 | { type: store.Store }
|
1189 | ]; };
|
1190 | return UnauthorizedInterceptor;
|
1191 | }());
|
1192 | if (false) {
|
1193 | |
1194 |
|
1195 |
|
1196 |
|
1197 | UnauthorizedInterceptor.prototype.router;
|
1198 | |
1199 |
|
1200 |
|
1201 |
|
1202 | UnauthorizedInterceptor.prototype.store;
|
1203 | }
|
1204 |
|
1205 | |
1206 |
|
1207 |
|
1208 |
|
1209 | |
1210 |
|
1211 |
|
1212 | function State() { }
|
1213 | if (false) {
|
1214 |
|
1215 | State.prototype.loggedIn;
|
1216 |
|
1217 | State.prototype.user;
|
1218 | }
|
1219 |
|
1220 | var initialState = {
|
1221 | loggedIn: false,
|
1222 | user: new UserModel({ Id: 1 })
|
1223 | };
|
1224 | |
1225 |
|
1226 |
|
1227 |
|
1228 |
|
1229 | function UserReducer(state, action) {
|
1230 | if (state === void 0) { state = initialState; }
|
1231 | switch (action.type) {
|
1232 | case SignInActionTypes.SIGNIN_SUCCEED: {
|
1233 | return __assign({}, state, { loggedIn: true, user: action.payload });
|
1234 | }
|
1235 | case SignInActionTypes.SIGNOUT: {
|
1236 | return __assign({}, state, { loggedIn: false, user: new UserModel() });
|
1237 | }
|
1238 | default: {
|
1239 | return state;
|
1240 | }
|
1241 | }
|
1242 | }
|
1243 |
|
1244 |
|
1245 | var getLoggedIn = ( |
1246 |
|
1247 |
|
1248 |
|
1249 | function (state) { return state.loggedIn; });
|
1250 |
|
1251 | var getUser = ( |
1252 |
|
1253 |
|
1254 |
|
1255 | function (state) { return state.user; });
|
1256 |
|
1257 | |
1258 |
|
1259 |
|
1260 |
|
1261 | |
1262 |
|
1263 |
|
1264 | function AuthenticationState() { }
|
1265 | if (false) {
|
1266 |
|
1267 | AuthenticationState.prototype.userStatus;
|
1268 | }
|
1269 | |
1270 |
|
1271 |
|
1272 | function FeatureState() { }
|
1273 | if (false) {
|
1274 |
|
1275 | FeatureState.prototype.authentication;
|
1276 | }
|
1277 |
|
1278 | var AuthenticationReducers = {
|
1279 | userStatus: UserReducer
|
1280 |
|
1281 | };
|
1282 |
|
1283 |
|
1284 | var selectAuthenticationState = store.createFeatureSelector("authentication");
|
1285 | var ɵ0$1 = |
1286 |
|
1287 |
|
1288 |
|
1289 | function (state) { return state.userStatus; };
|
1290 |
|
1291 | var selectAuthState = store.createSelector(selectAuthenticationState, (ɵ0$1));
|
1292 |
|
1293 | var getLoggedIn$1 = store.createSelector(selectAuthState, getLoggedIn);
|
1294 |
|
1295 | var getUser$1 = store.createSelector(selectAuthState, getUser);
|
1296 |
|
1297 | |
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 | |
1303 |
|
1304 |
|
1305 |
|
1306 | var SigninEffects = (function () {
|
1307 | function SigninEffects(actions$, router, signinService, configurationService, bottomSheet) {
|
1308 | var _this = this;
|
1309 | this.actions$ = actions$;
|
1310 | this.router = router;
|
1311 | this.signinService = signinService;
|
1312 | this.configurationService = configurationService;
|
1313 | this.bottomSheet = bottomSheet;
|
1314 | this.whoAmI$ = this.actions$.pipe(effects.ofType(SignInActionTypes.WHO_AM_I), operators.switchMap(( |
1315 |
|
1316 |
|
1317 | function () {
|
1318 | return _this.signinService
|
1319 | .whoAmI()
|
1320 | .pipe(operators.map(( |
1321 |
|
1322 |
|
1323 |
|
1324 | function (user) { return new SigninSecceed(user); })), operators.catchError(( |
1325 |
|
1326 |
|
1327 |
|
1328 | function (error) { return rxjs.of(new SigninFailed(error)); })));
|
1329 | })));
|
1330 | this.Signin$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN), operators.pluck("payload"), operators.switchMap(( |
1331 |
|
1332 |
|
1333 |
|
1334 | function (payload) {
|
1335 | return _this.signinService
|
1336 | .signin(payload)
|
1337 | .pipe(operators.map(( |
1338 |
|
1339 |
|
1340 |
|
1341 | function (user) { return new SigninSecceed(user); })), operators.catchError(( |
1342 |
|
1343 |
|
1344 |
|
1345 | function (error) { return rxjs.of(new SigninFailed(error)); })));
|
1346 | })));
|
1347 | this.signup$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNUP), operators.pluck("payload"), operators.switchMap(( |
1348 |
|
1349 |
|
1350 |
|
1351 | function (payload) {
|
1352 | return _this.signinService
|
1353 | .signup(payload)
|
1354 | .pipe(operators.map(( |
1355 |
|
1356 |
|
1357 |
|
1358 | function (user) { return new SignupSecceed(user); })), operators.catchError(( |
1359 |
|
1360 |
|
1361 |
|
1362 | function (error) { return rxjs.of(new SignupFailed(error)); })));
|
1363 | })));
|
1364 | this.signupSucceed$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNUP_SUCCEED), operators.tap(( |
1365 |
|
1366 |
|
1367 | function () {
|
1368 | debugger;
|
1369 | _this.router.navigate(["auth/signin"]);
|
1370 | })));
|
1371 | this.SignInRequired$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_REQUIRED), operators.tap(( |
1372 |
|
1373 |
|
1374 |
|
1375 | function (data) {
|
1376 |
|
1377 | var signinBottomSheetRef = _this.bottomSheet.open(SigninContainerComponent, {
|
1378 | panelClass: "clear-mat-card-box"
|
1379 | });
|
1380 | signinBottomSheetRef.instance.signedIn$.subscribe(( |
1381 |
|
1382 |
|
1383 | function () {
|
1384 | signinBottomSheetRef.dismiss();
|
1385 | }));
|
1386 | return signinBottomSheetRef;
|
1387 | })));
|
1388 | this.SigninSucceed$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_SUCCEED), operators.tap(( |
1389 |
|
1390 |
|
1391 |
|
1392 | function (data) {
|
1393 | if (location.pathname.indexOf("signin") > -1)
|
1394 | _this.router.navigate(["/"]);
|
1395 | })));
|
1396 | this.AfterSigninFiled$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_FAILURE), operators.map(( |
1397 |
|
1398 |
|
1399 | function () { return new NewCaptcha(); })));
|
1400 | this.DoSignout$ = this.actions$.pipe(effects.ofType(SignInActionTypes.DO_SIGNOUT), operators.switchMap(( |
1401 |
|
1402 |
|
1403 |
|
1404 | function (data) {
|
1405 | return _this.signinService.signout().pipe(operators.map(( |
1406 |
|
1407 |
|
1408 | function () { return new SignoutAction(); })), operators.catchError(( |
1409 |
|
1410 |
|
1411 |
|
1412 | function (err) {
|
1413 |
|
1414 | debugger;
|
1415 | return rxjs.of(err);
|
1416 | })));
|
1417 | })));
|
1418 |
|
1419 |
|
1420 | this.redirectToLoginPage$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_REDIRECT), operators.tap(( |
1421 |
|
1422 |
|
1423 |
|
1424 | function (authed) { return _this.router.navigate(["auth/signin"]); })));
|
1425 | this.redirectAfterSignout$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNOUT), operators.tap(( |
1426 |
|
1427 |
|
1428 |
|
1429 | function (authed) { return _this.router.navigate([_this.configurationService.config$.getValue().afterSignoutRedirectTo]); })));
|
1430 | }
|
1431 | SigninEffects.decorators = [
|
1432 | { type: core.Injectable }
|
1433 | ];
|
1434 |
|
1435 | SigninEffects.ctorParameters = function () { return [
|
1436 | { type: effects.Actions },
|
1437 | { type: router.Router },
|
1438 | { type: SigninService },
|
1439 | { type: AuthenticationConfigurationService },
|
1440 | { type: material.MatBottomSheet }
|
1441 | ]; };
|
1442 | __decorate([
|
1443 | effects.Effect(),
|
1444 | __metadata("design:type", Object)
|
1445 | ], SigninEffects.prototype, "whoAmI$", void 0);
|
1446 | __decorate([
|
1447 | effects.Effect(),
|
1448 | __metadata("design:type", Object)
|
1449 | ], SigninEffects.prototype, "Signin$", void 0);
|
1450 | __decorate([
|
1451 | effects.Effect(),
|
1452 | __metadata("design:type", Object)
|
1453 | ], SigninEffects.prototype, "signup$", void 0);
|
1454 | __decorate([
|
1455 | effects.Effect({ dispatch: false }),
|
1456 | __metadata("design:type", Object)
|
1457 | ], SigninEffects.prototype, "signupSucceed$", void 0);
|
1458 | __decorate([
|
1459 | effects.Effect({ dispatch: false }),
|
1460 | __metadata("design:type", Object)
|
1461 | ], SigninEffects.prototype, "SignInRequired$", void 0);
|
1462 | __decorate([
|
1463 | effects.Effect({ dispatch: false }),
|
1464 | __metadata("design:type", Object)
|
1465 | ], SigninEffects.prototype, "SigninSucceed$", void 0);
|
1466 | __decorate([
|
1467 | effects.Effect(),
|
1468 | __metadata("design:type", Object)
|
1469 | ], SigninEffects.prototype, "AfterSigninFiled$", void 0);
|
1470 | __decorate([
|
1471 | effects.Effect(),
|
1472 | __metadata("design:type", Object)
|
1473 | ], SigninEffects.prototype, "DoSignout$", void 0);
|
1474 | __decorate([
|
1475 | effects.Effect({ dispatch: false }),
|
1476 | __metadata("design:type", Object)
|
1477 | ], SigninEffects.prototype, "redirectToLoginPage$", void 0);
|
1478 | __decorate([
|
1479 | effects.Effect({ dispatch: false }),
|
1480 | __metadata("design:type", Object)
|
1481 | ], SigninEffects.prototype, "redirectAfterSignout$", void 0);
|
1482 | return SigninEffects;
|
1483 | }());
|
1484 | if (false) {
|
1485 |
|
1486 | SigninEffects.prototype.whoAmI$;
|
1487 |
|
1488 | SigninEffects.prototype.Signin$;
|
1489 |
|
1490 | SigninEffects.prototype.signup$;
|
1491 |
|
1492 | SigninEffects.prototype.signupSucceed$;
|
1493 |
|
1494 | SigninEffects.prototype.SignInRequired$;
|
1495 |
|
1496 | SigninEffects.prototype.SigninSucceed$;
|
1497 |
|
1498 | SigninEffects.prototype.AfterSigninFiled$;
|
1499 |
|
1500 | SigninEffects.prototype.DoSignout$;
|
1501 |
|
1502 | SigninEffects.prototype.redirectToLoginPage$;
|
1503 |
|
1504 | SigninEffects.prototype.redirectAfterSignout$;
|
1505 | |
1506 |
|
1507 |
|
1508 |
|
1509 | SigninEffects.prototype.actions$;
|
1510 | |
1511 |
|
1512 |
|
1513 |
|
1514 | SigninEffects.prototype.router;
|
1515 |
|
1516 | SigninEffects.prototype.signinService;
|
1517 |
|
1518 | SigninEffects.prototype.configurationService;
|
1519 | |
1520 |
|
1521 |
|
1522 |
|
1523 | SigninEffects.prototype.bottomSheet;
|
1524 | }
|
1525 |
|
1526 | |
1527 |
|
1528 |
|
1529 |
|
1530 | var AuthenticationEffects = (function () {
|
1531 | function AuthenticationEffects(actions$) {
|
1532 | this.actions$ = actions$;
|
1533 | this.dispachProgressingStarted$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN), operators.map(( |
1534 |
|
1535 |
|
1536 | function () { return new ProgressingStarted(); })));
|
1537 | this.dispachProgressingFinished$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_FAILURE, SignInActionTypes.SIGNIN_SUCCEED), operators.map(( |
1538 |
|
1539 |
|
1540 | function () { return new ProgressingFinished(); })));
|
1541 | }
|
1542 | AuthenticationEffects.decorators = [
|
1543 | { type: core.Injectable }
|
1544 | ];
|
1545 |
|
1546 | AuthenticationEffects.ctorParameters = function () { return [
|
1547 | { type: effects.Actions }
|
1548 | ]; };
|
1549 | __decorate([
|
1550 | effects.Effect(),
|
1551 | __metadata("design:type", Object)
|
1552 | ], AuthenticationEffects.prototype, "dispachProgressingStarted$", void 0);
|
1553 | __decorate([
|
1554 | effects.Effect(),
|
1555 | __metadata("design:type", Object)
|
1556 | ], AuthenticationEffects.prototype, "dispachProgressingFinished$", void 0);
|
1557 | return AuthenticationEffects;
|
1558 | }());
|
1559 | if (false) {
|
1560 |
|
1561 | AuthenticationEffects.prototype.dispachProgressingStarted$;
|
1562 |
|
1563 | AuthenticationEffects.prototype.dispachProgressingFinished$;
|
1564 | |
1565 |
|
1566 |
|
1567 |
|
1568 | AuthenticationEffects.prototype.actions$;
|
1569 | }
|
1570 |
|
1571 | |
1572 |
|
1573 |
|
1574 |
|
1575 | var SignupComponent = (function () {
|
1576 | function SignupComponent() {
|
1577 | this.signedup = new core.EventEmitter();
|
1578 | }
|
1579 | |
1580 |
|
1581 |
|
1582 |
|
1583 | SignupComponent.prototype.signup = |
1584 |
|
1585 |
|
1586 |
|
1587 | function (formGroup) {
|
1588 | if (!formGroup.valid)
|
1589 | return;
|
1590 | this.signedup.emit(formGroup.value);
|
1591 | };
|
1592 | SignupComponent.decorators = [
|
1593 | { type: core.Component, args: [{
|
1594 | selector: "auth-signup",
|
1595 | template: "<div fxLayout='row' fxLayoutAlign=\"center center\">\r\n <ngs-form-view \r\n [id]=\"formId\"\r\n [card]=\"true\"\r\n (accept)=\"signup($event)\"\r\n ></ngs-form-view>\r\n</div>\r\n<!-- <div>\r\n <a fxFlex=\"nogrow\" routerLink=\"/user/password/reset\" mat-raised-button fxFlexFill>\u06A9\u0644\u0645\u0647 \u0639\u0628\u0648\u0631 \u062E\u0648\u062F \u0631\u0627 \u0641\u0631\u0627\u0645\u0648\u0634 \u06A9\u0631\u062F\u0647 \u0627\u06CC\u062F\u061F</a>\r\n</div> -->",
|
1596 | styles: [""]
|
1597 | }] }
|
1598 | ];
|
1599 |
|
1600 | SignupComponent.ctorParameters = function () { return []; };
|
1601 | SignupComponent.propDecorators = {
|
1602 | signedup: [{ type: core.Output }],
|
1603 | formId: [{ type: core.Input }]
|
1604 | };
|
1605 | return SignupComponent;
|
1606 | }());
|
1607 | if (false) {
|
1608 |
|
1609 | SignupComponent.prototype.signedup;
|
1610 |
|
1611 | SignupComponent.prototype.formId;
|
1612 | }
|
1613 |
|
1614 | |
1615 |
|
1616 |
|
1617 |
|
1618 | var SigninGuard = (function () {
|
1619 | function SigninGuard(store) {
|
1620 | this.store = store;
|
1621 | }
|
1622 | |
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 | SigninGuard.prototype.canActivate = |
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 | function (route, state) {
|
1633 | return this.store.select(getLoggedIn$1).take(1).map(( |
1634 |
|
1635 |
|
1636 |
|
1637 | function (authed) { return !authed; }));
|
1638 | };
|
1639 | SigninGuard.decorators = [
|
1640 | { type: core.Injectable }
|
1641 | ];
|
1642 |
|
1643 | SigninGuard.ctorParameters = function () { return [
|
1644 | { type: store.Store }
|
1645 | ]; };
|
1646 | return SigninGuard;
|
1647 | }());
|
1648 | if (false) {
|
1649 | |
1650 |
|
1651 |
|
1652 |
|
1653 | SigninGuard.prototype.store;
|
1654 | }
|
1655 |
|
1656 | |
1657 |
|
1658 |
|
1659 |
|
1660 | var NgsAuthenticationModule = (function () {
|
1661 | function NgsAuthenticationModule() {
|
1662 | }
|
1663 | |
1664 |
|
1665 |
|
1666 |
|
1667 | NgsAuthenticationModule.forRoot = |
1668 |
|
1669 |
|
1670 |
|
1671 | function (config) {
|
1672 | if (config === void 0) { config = ( ({})); }
|
1673 | return {
|
1674 | ngModule: RootNgsAuthenticationModule,
|
1675 | providers: [
|
1676 | { provide: MODULE_CONFIG_TOKEN, useValue: config },
|
1677 | {
|
1678 | provide: http.HTTP_INTERCEPTORS,
|
1679 | useClass: UnauthorizedInterceptor,
|
1680 | multi: true
|
1681 | },
|
1682 | {
|
1683 | provide: http.HTTP_INTERCEPTORS,
|
1684 | useClass: WithCredentialInterceptor,
|
1685 | multi: true
|
1686 | },
|
1687 | SigninService
|
1688 | ]
|
1689 | };
|
1690 | };
|
1691 | NgsAuthenticationModule.decorators = [
|
1692 | { type: core.NgModule, args: [{
|
1693 | imports: [
|
1694 | common.CommonModule,
|
1695 | router.RouterModule,
|
1696 | forms.FormsModule,
|
1697 | http.HttpClientModule,
|
1698 | flexLayout.FlexLayoutModule,
|
1699 | material.MatIconModule,
|
1700 | material.MatButtonModule,
|
1701 | material.MatCardModule,
|
1702 | material.MatSnackBarModule,
|
1703 | material.MatSidenavModule,
|
1704 | material.MatExpansionModule,
|
1705 | material.MatSelectModule,
|
1706 | material.MatBottomSheetModule,
|
1707 | material.MatFormFieldModule,
|
1708 | material.MatListModule,
|
1709 | material.MatMenuModule,
|
1710 | material.MatRadioModule,
|
1711 | material.MatInputModule,
|
1712 | material.MatToolbarModule,
|
1713 | material.MatDatepickerModule,
|
1714 | material.MatProgressBarModule,
|
1715 | animations.BrowserAnimationsModule,
|
1716 | forms.ReactiveFormsModule,
|
1717 | forms.FormsModule,
|
1718 | form.NgsFormModule
|
1719 | ],
|
1720 | declarations: [
|
1721 | SigninContainerComponent,
|
1722 | SigninComponent,
|
1723 | AuthenticationContainerComponent,
|
1724 | SignupContainerComponent,
|
1725 | SignupComponent
|
1726 | ],
|
1727 | entryComponents: [SigninContainerComponent],
|
1728 | providers: [SigninGuard],
|
1729 | exports: []
|
1730 | },] }
|
1731 | ];
|
1732 | return NgsAuthenticationModule;
|
1733 | }());
|
1734 | var RootNgsAuthenticationModule = (function () {
|
1735 | function RootNgsAuthenticationModule() {
|
1736 | (( (window))).___starter = (( (window))).___starter || {};
|
1737 | (( (window))).___starter.authentication = "8.0.10";
|
1738 | }
|
1739 | RootNgsAuthenticationModule.decorators = [
|
1740 | { type: core.NgModule, args: [{
|
1741 | imports: [
|
1742 | store.StoreModule.forFeature("authentication", AuthenticationReducers),
|
1743 | effects.EffectsModule.forFeature([SigninEffects, AuthenticationEffects]),
|
1744 | AuthenticationRoutingModule,
|
1745 | NgsAuthenticationModule
|
1746 | ]
|
1747 | },] }
|
1748 | ];
|
1749 |
|
1750 | RootNgsAuthenticationModule.ctorParameters = function () { return []; };
|
1751 | return RootNgsAuthenticationModule;
|
1752 | }());
|
1753 |
|
1754 | exports.DoSignoutAction = DoSignoutAction;
|
1755 | exports.NgsAuthenticationModule = NgsAuthenticationModule;
|
1756 | exports.SignInActionTypes = SignInActionTypes;
|
1757 | exports.SigninContainerComponent = SigninContainerComponent;
|
1758 | exports.SigninRequiredAction = SigninRequiredAction;
|
1759 | exports.SigninService = SigninService;
|
1760 | exports.UserModel = UserModel;
|
1761 | exports.getUser = getUser$1;
|
1762 | exports.ɵa = MODULE_CONFIG_TOKEN;
|
1763 | exports.ɵb = RootNgsAuthenticationModule;
|
1764 | exports.ɵc = AuthenticationReducers;
|
1765 | exports.ɵd = selectAuthenticationState;
|
1766 | exports.ɵe = selectAuthState;
|
1767 | exports.ɵh = AuthenticationConfigurationService;
|
1768 | exports.ɵi = SigninComponent;
|
1769 | exports.ɵj = AuthenticationContainerComponent;
|
1770 | exports.ɵk = SignupContainerComponent;
|
1771 | exports.ɵl = SignupComponent;
|
1772 | exports.ɵm = SigninGuard;
|
1773 | exports.ɵn = UserReducer;
|
1774 | exports.ɵo = getUser;
|
1775 | exports.ɵp = SigninEffects;
|
1776 | exports.ɵq = AuthenticationEffects;
|
1777 | exports.ɵr = AuthenticationRoutingModule;
|
1778 | exports.ɵs = UnauthorizedInterceptor;
|
1779 | exports.ɵt = WithCredentialInterceptor;
|
1780 |
|
1781 | Object.defineProperty(exports, '__esModule', { value: true });
|
1782 |
|
1783 | }));
|
1784 |
|