UNPKG

70.1 kBJavaScriptView Raw
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 Copyright (c) Microsoft Corporation. All rights reserved.
9 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
10 this file except in compliance with the License. You may obtain a copy of the
11 License at http://www.apache.org/licenses/LICENSE-2.0
12
13 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
15 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
16 MERCHANTABLITY OR NON-INFRINGEMENT.
17
18 See the Apache Version 2.0 License for specific language governing permissions
19 and limitations under the License.
20 ***************************************************************************** */
21 /* global Reflect, Promise */
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 * @fileoverview added by tsickle
206 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
207 */
208 var UserModel = /** @class */ (function () {
209 function UserModel(params) {
210 var _this = this;
211 // IdentificationNo: string;
212 // IdentifierType: string;
213 // RegisterDate: string;
214 // UserType: string;
215 this.Roles = [];
216 params &&
217 Object.keys(params).forEach((/**
218 * @param {?} key
219 * @return {?}
220 */
221 function (key) {
222 if (key in params)
223 ((/** @type {?} */ (_this)))[key] = params[key];
224 }));
225 }
226 return UserModel;
227 }());
228 if (false) {
229 /** @type {?} */
230 UserModel.prototype._id;
231 /** @type {?} */
232 UserModel.prototype.Username;
233 /** @type {?} */
234 UserModel.prototype.Email;
235 /** @type {?} */
236 UserModel.prototype.Roles;
237 }
238
239 /**
240 * @fileoverview added by tsickle
241 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
242 */
243 /** @enum {string} */
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 = /** @class */ (function () {
258 function WhoAmIAction() {
259 this.type = SignInActionTypes.WHO_AM_I;
260 }
261 return WhoAmIAction;
262 }());
263 if (false) {
264 /** @type {?} */
265 WhoAmIAction.prototype.type;
266 }
267 /**
268 * sign up
269 */
270 var /**
271 * sign up
272 */
273 Signup = /** @class */ (function () {
274 function Signup(payload) {
275 this.payload = payload;
276 this.type = SignInActionTypes.SIGNUP;
277 }
278 return Signup;
279 }());
280 if (false) {
281 /** @type {?} */
282 Signup.prototype.type;
283 /** @type {?} */
284 Signup.prototype.payload;
285 }
286 var SignupSecceed = /** @class */ (function () {
287 function SignupSecceed(payload) {
288 this.payload = payload;
289 this.type = SignInActionTypes.SIGNUP_SUCCEED;
290 }
291 return SignupSecceed;
292 }());
293 if (false) {
294 /** @type {?} */
295 SignupSecceed.prototype.type;
296 /** @type {?} */
297 SignupSecceed.prototype.payload;
298 }
299 var SignupFailed = /** @class */ (function () {
300 function SignupFailed(payload) {
301 this.payload = payload;
302 this.type = SignInActionTypes.SIGNUP_FAILURE;
303 }
304 return SignupFailed;
305 }());
306 if (false) {
307 /** @type {?} */
308 SignupFailed.prototype.type;
309 /** @type {?} */
310 SignupFailed.prototype.payload;
311 }
312 /**
313 * Sign in
314 */
315 var /**
316 * Sign in
317 */
318 Signin = /** @class */ (function () {
319 function Signin(payload) {
320 this.payload = payload;
321 this.type = SignInActionTypes.SIGNIN;
322 }
323 return Signin;
324 }());
325 if (false) {
326 /** @type {?} */
327 Signin.prototype.type;
328 /** @type {?} */
329 Signin.prototype.payload;
330 }
331 var SigninSecceed = /** @class */ (function () {
332 function SigninSecceed(payload) {
333 this.payload = payload;
334 this.type = SignInActionTypes.SIGNIN_SUCCEED;
335 }
336 return SigninSecceed;
337 }());
338 if (false) {
339 /** @type {?} */
340 SigninSecceed.prototype.type;
341 /** @type {?} */
342 SigninSecceed.prototype.payload;
343 }
344 var SigninFailed = /** @class */ (function () {
345 function SigninFailed(payload) {
346 this.payload = payload;
347 this.type = SignInActionTypes.SIGNIN_FAILURE;
348 }
349 return SigninFailed;
350 }());
351 if (false) {
352 /** @type {?} */
353 SigninFailed.prototype.type;
354 /** @type {?} */
355 SigninFailed.prototype.payload;
356 }
357 var SigninRedirect = /** @class */ (function () {
358 function SigninRedirect() {
359 this.type = SignInActionTypes.SIGNIN_REDIRECT;
360 }
361 return SigninRedirect;
362 }());
363 if (false) {
364 /** @type {?} */
365 SigninRedirect.prototype.type;
366 }
367 var DoSignoutAction = /** @class */ (function () {
368 function DoSignoutAction() {
369 this.type = SignInActionTypes.DO_SIGNOUT;
370 }
371 return DoSignoutAction;
372 }());
373 if (false) {
374 /** @type {?} */
375 DoSignoutAction.prototype.type;
376 }
377 var SignoutAction = /** @class */ (function () {
378 function SignoutAction() {
379 this.type = SignInActionTypes.SIGNOUT;
380 }
381 return SignoutAction;
382 }());
383 if (false) {
384 /** @type {?} */
385 SignoutAction.prototype.type;
386 }
387 var SigninRequiredAction = /** @class */ (function () {
388 function SigninRequiredAction() {
389 this.type = SignInActionTypes.SIGNIN_REQUIRED;
390 }
391 return SigninRequiredAction;
392 }());
393 if (false) {
394 /** @type {?} */
395 SigninRequiredAction.prototype.type;
396 }
397
398 /**
399 * @fileoverview added by tsickle
400 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
401 */
402 /**
403 * @record
404 */
405 function AuthenticationModuleConfig() { }
406 if (false) {
407 /** @type {?|undefined} */
408 AuthenticationModuleConfig.prototype.mode;
409 /** @type {?|undefined} */
410 AuthenticationModuleConfig.prototype.token;
411 /** @type {?|undefined} */
412 AuthenticationModuleConfig.prototype.server;
413 /** @type {?|undefined} */
414 AuthenticationModuleConfig.prototype.endpoints;
415 /** @type {?|undefined} */
416 AuthenticationModuleConfig.prototype.forms;
417 /** @type {?|undefined} */
418 AuthenticationModuleConfig.prototype.env;
419 /** @type {?|undefined} */
420 AuthenticationModuleConfig.prototype.afterSignoutRedirectTo;
421 /** @type {?|undefined} */
422 AuthenticationModuleConfig.prototype.signupValidator;
423 /** @type {?|undefined} */
424 AuthenticationModuleConfig.prototype.afterSignin;
425 /** @type {?|undefined} */
426 AuthenticationModuleConfig.prototype.responseToUser;
427 }
428 var ɵ0 = /**
429 * @param {?} value
430 * @return {?}
431 */
432 function (value) { return rxjs.of(true); }, ɵ1 = /**
433 * @param {?} user
434 * @return {?}
435 */
436 function (user) { }, ɵ2 = /**
437 * @param {?} user
438 * @return {?}
439 */
440 function (user) { return user; };
441 /** @type {?} */
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 /** @type {?} */
470 var MODULE_CONFIG_TOKEN = new core.InjectionToken("ModuleConfig");
471
472 /**
473 * @fileoverview added by tsickle
474 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
475 */
476 var AuthenticationConfigurationService = /** @class */ (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 * @param {?} storeConfig
485 * @return {?}
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 /** @nocollapse */
510 AuthenticationConfigurationService.ctorParameters = function () { return [
511 { type: undefined, decorators: [{ type: core.Inject, args: [MODULE_CONFIG_TOKEN,] }] },
512 { type: store.Store }
513 ]; };
514 /** @nocollapse */ 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 * @type {?}
520 * @private
521 */
522 AuthenticationConfigurationService.prototype._config;
523 /** @type {?} */
524 AuthenticationConfigurationService.prototype.config$;
525 /**
526 * @type {?}
527 * @private
528 */
529 AuthenticationConfigurationService.prototype.store;
530 }
531
532 /**
533 * @fileoverview added by tsickle
534 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
535 */
536 /** @enum {string} */
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 = /** @class */ (function () {
543 function ProgressingStarted() {
544 this.type = "[AUTHENTICATION] PROGRESSING_STARTED" /* PROGRESSING_STARTED */;
545 }
546 return ProgressingStarted;
547 }());
548 if (false) {
549 /** @type {?} */
550 ProgressingStarted.prototype.type;
551 }
552 var ProgressingFinished = /** @class */ (function () {
553 function ProgressingFinished() {
554 this.type = "[AUTHENTICATION] PROGRESSING_FINISHED" /* PROGRESSING_FINISHED */;
555 }
556 return ProgressingFinished;
557 }());
558 if (false) {
559 /** @type {?} */
560 ProgressingFinished.prototype.type;
561 }
562 var FailedHappened = /** @class */ (function () {
563 function FailedHappened(payload) {
564 this.payload = payload;
565 this.type = "[AUTHENTICATION] FAILED_HAPPENED" /* FAILED_HAPPENED */;
566 }
567 return FailedHappened;
568 }());
569 if (false) {
570 /** @type {?} */
571 FailedHappened.prototype.type;
572 /** @type {?} */
573 FailedHappened.prototype.payload;
574 }
575
576 /**
577 * @fileoverview added by tsickle
578 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
579 */
580 /** @type {?} */
581 var NEW_CAPTCHA = '[captcha] new captcha';
582 /** @type {?} */
583 var TOKEN_REQUESTED = '[captcha] token_requested';
584 /** @type {?} */
585 var TOKEN_RECEIVED = '[captcha] token_received';
586 /** @type {?} */
587 var CAPTCHA_IMAGE_REQUESTED = '[captcha] captcha_image_requested';
588 /** @type {?} */
589 var CAPTCHA_IMAGE_LOADED = '[captcha] captcha_image_loaded';
590 /** @type {?} */
591 var CAPTCHA_ENTERED = '[captcha] CAPTCHA_ENTERED';
592 /** @type {?} */
593 var CLEAR_CAPTCHA = '[captcha] CLEAR_CAPTCHA';
594 var NewCaptcha = /** @class */ (function () {
595 function NewCaptcha() {
596 this.type = NEW_CAPTCHA;
597 }
598 return NewCaptcha;
599 }());
600 if (false) {
601 /** @type {?} */
602 NewCaptcha.prototype.type;
603 }
604 var TokenRequested = /** @class */ (function () {
605 function TokenRequested() {
606 this.type = TOKEN_REQUESTED;
607 }
608 return TokenRequested;
609 }());
610 if (false) {
611 /** @type {?} */
612 TokenRequested.prototype.type;
613 }
614 var TokenReceived = /** @class */ (function () {
615 function TokenReceived(payload) {
616 this.payload = payload;
617 this.type = TOKEN_RECEIVED;
618 }
619 return TokenReceived;
620 }());
621 if (false) {
622 /** @type {?} */
623 TokenReceived.prototype.type;
624 /** @type {?} */
625 TokenReceived.prototype.payload;
626 }
627 var CaptchaImageRequested = /** @class */ (function () {
628 function CaptchaImageRequested() {
629 this.type = CAPTCHA_IMAGE_REQUESTED;
630 }
631 return CaptchaImageRequested;
632 }());
633 if (false) {
634 /** @type {?} */
635 CaptchaImageRequested.prototype.type;
636 }
637 var CaptchaImageLoaded = /** @class */ (function () {
638 function CaptchaImageLoaded() {
639 this.type = CAPTCHA_IMAGE_LOADED;
640 }
641 return CaptchaImageLoaded;
642 }());
643 if (false) {
644 /** @type {?} */
645 CaptchaImageLoaded.prototype.type;
646 }
647 var CaptchaEntered = /** @class */ (function () {
648 function CaptchaEntered(payload) {
649 this.payload = payload;
650 this.type = CAPTCHA_ENTERED;
651 }
652 return CaptchaEntered;
653 }());
654 if (false) {
655 /** @type {?} */
656 CaptchaEntered.prototype.type;
657 /** @type {?} */
658 CaptchaEntered.prototype.payload;
659 }
660 var ClearCaptcha = /** @class */ (function () {
661 function ClearCaptcha() {
662 this.type = CLEAR_CAPTCHA;
663 }
664 return ClearCaptcha;
665 }());
666 if (false) {
667 /** @type {?} */
668 ClearCaptcha.prototype.type;
669 }
670
671 /**
672 * @fileoverview added by tsickle
673 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
674 */
675
676 /**
677 * @fileoverview added by tsickle
678 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
679 */
680 /** @type {?} */
681 var COOKIE_NAME = "ngs-authentication";
682 var SigninService = /** @class */ (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 * @return {?}
691 */
692 function () { return _this.store.dispatch(new WhoAmIAction()); }), 300);
693 }
694 /**
695 * @param {?} model
696 * @return {?}
697 */
698 SigninService.prototype.signup = /**
699 * @param {?} model
700 * @return {?}
701 */
702 function (model) {
703 var _this = this;
704 return this.configurationService.config$.pipe(operators.filter((/**
705 * @param {?} config
706 * @return {?}
707 */
708 function (config) { return config.endpoints.signUp != ""; })), operators.take(1), operators.switchMap((/**
709 * @param {?} config
710 * @return {?}
711 */
712 function (config) {
713 return _this.http.post(config.env[config.server] + config.endpoints.signUp, model);
714 })), operators.map((/**
715 * @param {?} response
716 * @return {?}
717 */
718 function (response) {
719 /** @type {?} */
720 var user = Object.assign({}, response.Result);
721 if (user.Role) {
722 user.Roles = [user.Role];
723 }
724 return user;
725 })));
726 };
727 /**
728 * @param {?} model
729 * @return {?}
730 */
731 SigninService.prototype.signin = /**
732 * @param {?} model
733 * @return {?}
734 */
735 function (model) {
736 var _this = this;
737 return this.configurationService.config$.pipe(operators.filter((/**
738 * @param {?} config
739 * @return {?}
740 */
741 function (config) { return config.endpoints.signIn != ""; })), operators.take(1), operators.switchMap((/**
742 * @param {?} config
743 * @return {?}
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 * @param {?} user
747 * @return {?}
748 */
749 function (user) {
750 if (user.Role) {
751 user.Roles = [user.Role];
752 }
753 return user;
754 })), operators.tap((/**
755 * @param {?} user
756 * @return {?}
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 * @param {?} user
763 * @return {?}
764 */
765 function (user) { return _this.configurationService.config.afterSignin(user); })));
766 };
767 // TODO:
768 // TODO:
769 /**
770 * @return {?}
771 */
772 SigninService.prototype.signout =
773 // TODO:
774 /**
775 * @return {?}
776 */
777 function () {
778 /** @type {?} */
779 var config = this.configurationService.config;
780 /** @type {?} */
781 var tokenObject = JSON.parse(shared.Cookie.getCookie(COOKIE_NAME));
782 /** @type {?} */
783 var endpoint = shared.stringTemplate(config.env[config.server] + config.endpoints.signOut, tokenObject);
784 /** @type {?} */
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 * @return {?}
791 */
792 function () {
793 shared.Cookie.deleteCookie(COOKIE_NAME);
794 })));
795 };
796 /**
797 * @return {?}
798 */
799 SigninService.prototype.whoAmI = /**
800 * @return {?}
801 */
802 function () {
803 var _this = this;
804 debugger;
805 /** @type {?} */
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 * @param {?} config
815 * @return {?}
816 */
817 function (config) { return config.endpoints.whoAmI != ""; })), operators.take(1), operators.switchMap((/**
818 * @param {?} config
819 * @return {?}
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 /** @nocollapse */
831 SigninService.ctorParameters = function () { return [
832 { type: http.HttpClient },
833 { type: store.Store },
834 { type: AuthenticationConfigurationService },
835 { type: material.MatSnackBar }
836 ]; };
837 /** @nocollapse */ 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 * @type {?}
843 * @private
844 */
845 SigninService.prototype.http;
846 /**
847 * @type {?}
848 * @private
849 */
850 SigninService.prototype.store;
851 /**
852 * @type {?}
853 * @private
854 */
855 SigninService.prototype.configurationService;
856 /**
857 * @type {?}
858 * @private
859 */
860 SigninService.prototype.snackBar;
861 }
862
863 /**
864 * @fileoverview added by tsickle
865 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
866 */
867 var SigninContainerComponent = /** @class */ (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 * @param {?} config
874 * @return {?}
875 */
876 function (config) { return config.forms.signIn; }));
877 }
878 /**
879 * @param {?} formValue
880 * @return {?}
881 */
882 SigninContainerComponent.prototype.signIn = /**
883 * @param {?} formValue
884 * @return {?}
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 /** @nocollapse */
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 /** @type {?} */
907 SigninContainerComponent.prototype.formId$;
908 /** @type {?} */
909 SigninContainerComponent.prototype.signedIn$;
910 /**
911 * @type {?}
912 * @private
913 */
914 SigninContainerComponent.prototype.configurationService;
915 /**
916 * @type {?}
917 * @private
918 */
919 SigninContainerComponent.prototype.store;
920 }
921
922 /**
923 * @fileoverview added by tsickle
924 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
925 */
926 var AuthenticationContainerComponent = /** @class */ (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 * @fileoverview added by tsickle
939 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
940 */
941 var SignupContainerComponent = /** @class */ (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 * @param {?} config
949 * @return {?}
950 */
951 function (config) { return config.forms.signUp; }));
952 }
953 /**
954 * @param {?} formValue
955 * @return {?}
956 */
957 SignupContainerComponent.prototype.signup = /**
958 * @param {?} formValue
959 * @return {?}
960 */
961 function (formValue) {
962 var _this = this;
963 this.configurationService.config$
964 .pipe(operators.take(1), operators.switchMap((/**
965 * @param {?} config
966 * @return {?}
967 */
968 function (config) { return config.signupValidator(formValue); })))
969 .subscribe((/**
970 * @param {?} validation
971 * @return {?}
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 /** @nocollapse */
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 /** @type {?} */
1003 SignupContainerComponent.prototype.formId$;
1004 /** @type {?} */
1005 SignupContainerComponent.prototype.signedUp$;
1006 /**
1007 * @type {?}
1008 * @private
1009 */
1010 SignupContainerComponent.prototype.configurationService;
1011 /**
1012 * @type {?}
1013 * @private
1014 */
1015 SignupContainerComponent.prototype.store;
1016 /**
1017 * @type {?}
1018 * @private
1019 */
1020 SignupContainerComponent.prototype.snackBar;
1021 }
1022
1023 /**
1024 * @fileoverview added by tsickle
1025 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1026 */
1027 /** @type {?} */
1028 var routes = [
1029 {
1030 path: "auth",
1031 component: AuthenticationContainerComponent,
1032 children: [
1033 {
1034 path: "signin",
1035 // canActivate: [ SigninGuard ],
1036 component: SigninContainerComponent
1037 },
1038 {
1039 path: "signup",
1040 // canActivate: [ SigninGuard ],
1041 component: SignupContainerComponent
1042 }
1043 ]
1044 }
1045 ];
1046 /** @type {?} */
1047 var AuthenticationRoutingModule = router.RouterModule.forChild(routes);
1048
1049 /**
1050 * @fileoverview added by tsickle
1051 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1052 */
1053 var SigninComponent = /** @class */ (function () {
1054 function SigninComponent() {
1055 this.signedin = new core.EventEmitter();
1056 }
1057 /**
1058 * @param {?} formGroup
1059 * @return {?}
1060 */
1061 SigninComponent.prototype.signin = /**
1062 * @param {?} formGroup
1063 * @return {?}
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 /** @nocollapse */
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 /** @type {?} */
1087 SigninComponent.prototype.signedin;
1088 /** @type {?} */
1089 SigninComponent.prototype.formId;
1090 }
1091
1092 /**
1093 * @fileoverview added by tsickle
1094 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1095 */
1096 // import { environment } from "../../../environments/environment";
1097 var WithCredentialInterceptor = /** @class */ (function () {
1098 function WithCredentialInterceptor(configurationService) {
1099 this.configurationService = configurationService;
1100 }
1101 /**
1102 * @param {?} request
1103 * @param {?} next
1104 * @return {?}
1105 */
1106 WithCredentialInterceptor.prototype.intercept = /**
1107 * @param {?} request
1108 * @param {?} next
1109 * @return {?}
1110 */
1111 function (request, next) {
1112 // if (!this.configurationService.config.env.production)
1113 ((/** @type {?} */ (request))).withCredentials = true;
1114 return next.handle(request);
1115 };
1116 WithCredentialInterceptor.decorators = [
1117 { type: core.Injectable }
1118 ];
1119 /** @nocollapse */
1120 WithCredentialInterceptor.ctorParameters = function () { return [
1121 { type: AuthenticationConfigurationService }
1122 ]; };
1123 return WithCredentialInterceptor;
1124 }());
1125 if (false) {
1126 /**
1127 * @type {?}
1128 * @private
1129 */
1130 WithCredentialInterceptor.prototype.configurationService;
1131 }
1132
1133 /**
1134 * @fileoverview added by tsickle
1135 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1136 */
1137 var UnauthorizedInterceptor = /** @class */ (function () {
1138 function UnauthorizedInterceptor(router, store // private signinService: SigninService
1139 ) {
1140 this.router = router;
1141 this.store = store;
1142 }
1143 /**
1144 * @param {?} request
1145 * @param {?} next
1146 * @return {?}
1147 */
1148 UnauthorizedInterceptor.prototype.intercept = /**
1149 * @param {?} request
1150 * @param {?} next
1151 * @return {?}
1152 */
1153 function (request, next) {
1154 var _this = this;
1155 return next
1156 .handle(request)
1157 .map((/**
1158 * @param {?} event
1159 * @return {?}
1160 */
1161 function (event) {
1162 if (event instanceof http.HttpResponse)
1163 return event;
1164 }))
1165 .catch((/**
1166 * @param {?} err
1167 * @return {?}
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 /** @nocollapse */
1186 UnauthorizedInterceptor.ctorParameters = function () { return [
1187 { type: router.Router },
1188 { type: store.Store }
1189 ]; };
1190 return UnauthorizedInterceptor;
1191 }());
1192 if (false) {
1193 /**
1194 * @type {?}
1195 * @private
1196 */
1197 UnauthorizedInterceptor.prototype.router;
1198 /**
1199 * @type {?}
1200 * @private
1201 */
1202 UnauthorizedInterceptor.prototype.store;
1203 }
1204
1205 /**
1206 * @fileoverview added by tsickle
1207 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1208 */
1209 /**
1210 * @record
1211 */
1212 function State() { }
1213 if (false) {
1214 /** @type {?} */
1215 State.prototype.loggedIn;
1216 /** @type {?} */
1217 State.prototype.user;
1218 }
1219 /** @type {?} */
1220 var initialState = {
1221 loggedIn: false,
1222 user: new UserModel({ Id: 1 })
1223 };
1224 /**
1225 * @param {?=} state
1226 * @param {?=} action
1227 * @return {?}
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 //#region selectors
1244 /** @type {?} */
1245 var getLoggedIn = (/**
1246 * @param {?} state
1247 * @return {?}
1248 */
1249 function (state) { return state.loggedIn; });
1250 /** @type {?} */
1251 var getUser = (/**
1252 * @param {?} state
1253 * @return {?}
1254 */
1255 function (state) { return state.user; });
1256
1257 /**
1258 * @fileoverview added by tsickle
1259 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1260 */
1261 /**
1262 * @record
1263 */
1264 function AuthenticationState() { }
1265 if (false) {
1266 /** @type {?} */
1267 AuthenticationState.prototype.userStatus;
1268 }
1269 /**
1270 * @record
1271 */
1272 function FeatureState() { }
1273 if (false) {
1274 /** @type {?} */
1275 FeatureState.prototype.authentication;
1276 }
1277 /** @type {?} */
1278 var AuthenticationReducers = {
1279 userStatus: UserReducer
1280 // captcha: captchaReducer.CaptchaReducer
1281 };
1282 //#region selectors
1283 /** @type {?} */
1284 var selectAuthenticationState = store.createFeatureSelector("authentication");
1285 var ɵ0$1 = /**
1286 * @param {?} state
1287 * @return {?}
1288 */
1289 function (state) { return state.userStatus; };
1290 /** @type {?} */
1291 var selectAuthState = store.createSelector(selectAuthenticationState, (ɵ0$1));
1292 /** @type {?} */
1293 var getLoggedIn$1 = store.createSelector(selectAuthState, getLoggedIn);
1294 /** @type {?} */
1295 var getUser$1 = store.createSelector(selectAuthState, getUser);
1296
1297 /**
1298 * @fileoverview added by tsickle
1299 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1300 */
1301
1302 /**
1303 * @fileoverview added by tsickle
1304 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1305 */
1306 var SigninEffects = /** @class */ (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 * @return {?}
1316 */
1317 function () {
1318 return _this.signinService
1319 .whoAmI()
1320 .pipe(operators.map((/**
1321 * @param {?} user
1322 * @return {?}
1323 */
1324 function (user) { return new SigninSecceed(user); })), operators.catchError((/**
1325 * @param {?} error
1326 * @return {?}
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 * @param {?} payload
1332 * @return {?}
1333 */
1334 function (payload) {
1335 return _this.signinService
1336 .signin(payload)
1337 .pipe(operators.map((/**
1338 * @param {?} user
1339 * @return {?}
1340 */
1341 function (user) { return new SigninSecceed(user); })), operators.catchError((/**
1342 * @param {?} error
1343 * @return {?}
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 * @param {?} payload
1349 * @return {?}
1350 */
1351 function (payload) {
1352 return _this.signinService
1353 .signup(payload)
1354 .pipe(operators.map((/**
1355 * @param {?} user
1356 * @return {?}
1357 */
1358 function (user) { return new SignupSecceed(user); })), operators.catchError((/**
1359 * @param {?} error
1360 * @return {?}
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 * @return {?}
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 * @param {?} data
1373 * @return {?}
1374 */
1375 function (data) {
1376 /** @type {?} */
1377 var signinBottomSheetRef = _this.bottomSheet.open(SigninContainerComponent, {
1378 panelClass: "clear-mat-card-box"
1379 });
1380 signinBottomSheetRef.instance.signedIn$.subscribe((/**
1381 * @return {?}
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 * @param {?} data
1390 * @return {?}
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 * @return {?}
1398 */
1399 function () { return new NewCaptcha(); })));
1400 this.DoSignout$ = this.actions$.pipe(effects.ofType(SignInActionTypes.DO_SIGNOUT), operators.switchMap((/**
1401 * @param {?} data
1402 * @return {?}
1403 */
1404 function (data) {
1405 return _this.signinService.signout().pipe(operators.map((/**
1406 * @return {?}
1407 */
1408 function () { return new SignoutAction(); })), operators.catchError((/**
1409 * @param {?} err
1410 * @return {?}
1411 */
1412 function (err) {
1413 // TODO: dispatch valid action
1414 debugger;
1415 return rxjs.of(err);
1416 })));
1417 })));
1418 // TODO
1419 // @Effect() Signout$ = this.actions$.ofType(SignInActionTypes.DO_SIGNOUT).pipe(map(() => new SignoutAction()));
1420 this.redirectToLoginPage$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_REDIRECT), operators.tap((/**
1421 * @param {?} authed
1422 * @return {?}
1423 */
1424 function (authed) { return _this.router.navigate(["auth/signin"]); })));
1425 this.redirectAfterSignout$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNOUT), operators.tap((/**
1426 * @param {?} authed
1427 * @return {?}
1428 */
1429 function (authed) { return _this.router.navigate([_this.configurationService.config$.getValue().afterSignoutRedirectTo]); })));
1430 }
1431 SigninEffects.decorators = [
1432 { type: core.Injectable }
1433 ];
1434 /** @nocollapse */
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 /** @type {?} */
1486 SigninEffects.prototype.whoAmI$;
1487 /** @type {?} */
1488 SigninEffects.prototype.Signin$;
1489 /** @type {?} */
1490 SigninEffects.prototype.signup$;
1491 /** @type {?} */
1492 SigninEffects.prototype.signupSucceed$;
1493 /** @type {?} */
1494 SigninEffects.prototype.SignInRequired$;
1495 /** @type {?} */
1496 SigninEffects.prototype.SigninSucceed$;
1497 /** @type {?} */
1498 SigninEffects.prototype.AfterSigninFiled$;
1499 /** @type {?} */
1500 SigninEffects.prototype.DoSignout$;
1501 /** @type {?} */
1502 SigninEffects.prototype.redirectToLoginPage$;
1503 /** @type {?} */
1504 SigninEffects.prototype.redirectAfterSignout$;
1505 /**
1506 * @type {?}
1507 * @private
1508 */
1509 SigninEffects.prototype.actions$;
1510 /**
1511 * @type {?}
1512 * @private
1513 */
1514 SigninEffects.prototype.router;
1515 /** @type {?} */
1516 SigninEffects.prototype.signinService;
1517 /** @type {?} */
1518 SigninEffects.prototype.configurationService;
1519 /**
1520 * @type {?}
1521 * @private
1522 */
1523 SigninEffects.prototype.bottomSheet;
1524 }
1525
1526 /**
1527 * @fileoverview added by tsickle
1528 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1529 */
1530 var AuthenticationEffects = /** @class */ (function () {
1531 function AuthenticationEffects(actions$) {
1532 this.actions$ = actions$;
1533 this.dispachProgressingStarted$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN), operators.map((/**
1534 * @return {?}
1535 */
1536 function () { return new ProgressingStarted(); })));
1537 this.dispachProgressingFinished$ = this.actions$.pipe(effects.ofType(SignInActionTypes.SIGNIN_FAILURE, SignInActionTypes.SIGNIN_SUCCEED), operators.map((/**
1538 * @return {?}
1539 */
1540 function () { return new ProgressingFinished(); })));
1541 }
1542 AuthenticationEffects.decorators = [
1543 { type: core.Injectable }
1544 ];
1545 /** @nocollapse */
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 /** @type {?} */
1561 AuthenticationEffects.prototype.dispachProgressingStarted$;
1562 /** @type {?} */
1563 AuthenticationEffects.prototype.dispachProgressingFinished$;
1564 /**
1565 * @type {?}
1566 * @private
1567 */
1568 AuthenticationEffects.prototype.actions$;
1569 }
1570
1571 /**
1572 * @fileoverview added by tsickle
1573 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1574 */
1575 var SignupComponent = /** @class */ (function () {
1576 function SignupComponent() {
1577 this.signedup = new core.EventEmitter();
1578 }
1579 /**
1580 * @param {?} formGroup
1581 * @return {?}
1582 */
1583 SignupComponent.prototype.signup = /**
1584 * @param {?} formGroup
1585 * @return {?}
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 /** @nocollapse */
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 /** @type {?} */
1609 SignupComponent.prototype.signedup;
1610 /** @type {?} */
1611 SignupComponent.prototype.formId;
1612 }
1613
1614 /**
1615 * @fileoverview added by tsickle
1616 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1617 */
1618 var SigninGuard = /** @class */ (function () {
1619 function SigninGuard(store) {
1620 this.store = store;
1621 }
1622 /**
1623 * @param {?} route
1624 * @param {?} state
1625 * @return {?}
1626 */
1627 SigninGuard.prototype.canActivate = /**
1628 * @param {?} route
1629 * @param {?} state
1630 * @return {?}
1631 */
1632 function (route, state) {
1633 return this.store.select(getLoggedIn$1).take(1).map((/**
1634 * @param {?} authed
1635 * @return {?}
1636 */
1637 function (authed) { return !authed; }));
1638 };
1639 SigninGuard.decorators = [
1640 { type: core.Injectable }
1641 ];
1642 /** @nocollapse */
1643 SigninGuard.ctorParameters = function () { return [
1644 { type: store.Store }
1645 ]; };
1646 return SigninGuard;
1647 }());
1648 if (false) {
1649 /**
1650 * @type {?}
1651 * @private
1652 */
1653 SigninGuard.prototype.store;
1654 }
1655
1656 /**
1657 * @fileoverview added by tsickle
1658 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1659 */
1660 var NgsAuthenticationModule = /** @class */ (function () {
1661 function NgsAuthenticationModule() {
1662 }
1663 /**
1664 * @param {?=} config
1665 * @return {?}
1666 */
1667 NgsAuthenticationModule.forRoot = /**
1668 * @param {?=} config
1669 * @return {?}
1670 */
1671 function (config) {
1672 if (config === void 0) { config = (/** @type {?} */ ({})); }
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 = /** @class */ (function () {
1735 function RootNgsAuthenticationModule() {
1736 ((/** @type {?} */ (window))).___starter = ((/** @type {?} */ (window))).___starter || {};
1737 ((/** @type {?} */ (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 /** @nocollapse */
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//# sourceMappingURL=soushians-authentication.umd.js.map