UNPKG

32.2 kBJavaScriptView Raw
1import { stringTemplate, Cookie } from '@soushians/shared';
2import { getAuthenticationModuleConfig } from '@soushians/config';
3import { MatSnackBar as MatSnackBar$1 } from '@angular/material/snack-bar';
4import { CommonModule } from '@angular/common';
5import { FlexLayoutModule } from '@angular/flex-layout';
6import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7import { FormsModule, ReactiveFormsModule } from '@angular/forms';
8import { NgsFormModule } from '@soushians/form';
9import 'rxjs/add/operator/do';
10import { HttpClient, HttpResponse, HttpErrorResponse, HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
11import { of, BehaviorSubject, throwError } from 'rxjs';
12import { MatSnackBar, MatBottomSheet, MatIconModule, MatButtonModule, MatCardModule, MatSnackBarModule, MatSidenavModule, MatExpansionModule, MatSelectModule, MatFormFieldModule, MatListModule, MatMenuModule, MatRadioModule, MatInputModule, MatToolbarModule, MatDatepickerModule, MatProgressBarModule, MatBottomSheetModule } from '@angular/material';
13import { __decorate, __metadata } from 'tslib';
14import { RouterModule, Router } from '@angular/router';
15import 'rxjs/add/operator/map';
16import 'rxjs/add/operator/mergeMap';
17import { Actions, Effect, EffectsModule } from '@ngrx/effects';
18import { map, switchMap, take, filter, tap, catchError, pluck } from 'rxjs/operators';
19import { InjectionToken, Injectable, Inject, Component, Input, Output, EventEmitter, NgModule, defineInjectable, inject } from '@angular/core';
20import { Store, createSelector, createFeatureSelector, StoreModule } from '@ngrx/store';
21
22/**
23 * @fileoverview added by tsickle
24 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
25 */
26class UserModel {
27 /**
28 * @param {?=} params
29 */
30 constructor(params) {
31 // IdentificationNo: string;
32 // IdentifierType: string;
33 // RegisterDate: string;
34 // UserType: string;
35 this.Roles = [];
36 params &&
37 Object.keys(params).forEach(key => {
38 if (key in params)
39 (/** @type {?} */ (this))[key] = params[key];
40 });
41 }
42}
43
44/**
45 * @fileoverview added by tsickle
46 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
47 */
48/** @enum {string} */
49var SignInActionTypes = {
50 WHO_AM_I: "[AUTHENTICATION] who am i",
51 SIGNUP: "[AUTHENTICATION][SIGNUP] start",
52 SIGNUP_SUCCEED: "[AUTHENTICATION][SIGNUP] Success",
53 SIGNUP_FAILURE: "[AUTHENTICATION][SIGNUP] Failure",
54 SIGNIN: "[AUTHENTICATION] Signin",
55 DO_SIGNOUT: "[AUTHENTICATION] Do Signout",
56 SIGNOUT: "[AUTHENTICATION] Signout",
57 SIGNIN_SUCCEED: "[AUTHENTICATION][Signin] Success",
58 SIGNIN_FAILURE: "[AUTHENTICATION][Signin] Failure",
59 SIGNIN_REDIRECT: "[AUTHENTICATION][Signin] Redirect",
60 SIGNIN_REQUIRED: "[AUTHENTICATION][Signin] Required",
61};
62class WhoAmIAction {
63 constructor() {
64 this.type = SignInActionTypes.WHO_AM_I;
65 }
66}
67/**
68 * sign up
69 */
70class Signup {
71 /**
72 * @param {?} payload
73 */
74 constructor(payload) {
75 this.payload = payload;
76 this.type = SignInActionTypes.SIGNUP;
77 }
78}
79class SignupSecceed {
80 /**
81 * @param {?} payload
82 */
83 constructor(payload) {
84 this.payload = payload;
85 this.type = SignInActionTypes.SIGNUP_SUCCEED;
86 }
87}
88class SignupFailed {
89 /**
90 * @param {?} payload
91 */
92 constructor(payload) {
93 this.payload = payload;
94 this.type = SignInActionTypes.SIGNUP_FAILURE;
95 }
96}
97/**
98 * Sign in
99 */
100class Signin {
101 /**
102 * @param {?} payload
103 */
104 constructor(payload) {
105 this.payload = payload;
106 this.type = SignInActionTypes.SIGNIN;
107 }
108}
109class SigninSecceed {
110 /**
111 * @param {?} payload
112 */
113 constructor(payload) {
114 this.payload = payload;
115 this.type = SignInActionTypes.SIGNIN_SUCCEED;
116 }
117}
118class SigninFailed {
119 /**
120 * @param {?} payload
121 */
122 constructor(payload) {
123 this.payload = payload;
124 this.type = SignInActionTypes.SIGNIN_FAILURE;
125 }
126}
127class DoSignoutAction {
128 constructor() {
129 this.type = SignInActionTypes.DO_SIGNOUT;
130 }
131}
132class SignoutAction {
133 constructor() {
134 this.type = SignInActionTypes.SIGNOUT;
135 }
136}
137class SigninRequiredAction {
138 constructor() {
139 this.type = SignInActionTypes.SIGNIN_REQUIRED;
140 }
141}
142
143/**
144 * @fileoverview added by tsickle
145 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
146 */
147/** @type {?} */
148const MODULE_DEFAULT_CONFIG = {
149 mode: "cookie-base",
150 token: {
151 time: 24 * 12 * 60 * 60
152 },
153 server: "frontend_server",
154 endpoints: {
155 signOut: "",
156 signIn: "",
157 signUp: "",
158 whoAmI: ""
159 },
160 forms: {
161 signIn: "",
162 signUp: ""
163 },
164 env: {
165 production: false,
166 frontend_server: "auth/module/frontend_server/did/not/set",
167 server: "auth/module/server/did/not/set"
168 },
169 afterSignoutRedirectTo: "/",
170 signupValidator: value => of(true),
171 afterSignin: (user) => { },
172 responseToUser: user => user
173};
174/** @type {?} */
175const MODULE_CONFIG_TOKEN = new InjectionToken("ModuleConfig");
176
177/**
178 * @fileoverview added by tsickle
179 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
180 */
181class AuthenticationConfigurationService {
182 /**
183 * @param {?} configFile
184 * @param {?} store
185 */
186 constructor(configFile, store) {
187 this.store = store;
188 this.config$ = new BehaviorSubject(this._config);
189 this._config = Object.assign({}, MODULE_DEFAULT_CONFIG, configFile);
190 this.config$.next(this._config);
191 this.store.select(getAuthenticationModuleConfig).subscribe(storeConfig => {
192 if (!storeConfig)
193 return;
194 this._config = Object.assign({}, this._config, storeConfig.Config);
195 this.config$.next(this._config);
196 });
197 }
198 /**
199 * @return {?}
200 */
201 get config() {
202 return this._config;
203 }
204}
205AuthenticationConfigurationService.decorators = [
206 { type: Injectable, args: [{
207 providedIn: "root"
208 },] }
209];
210/** @nocollapse */
211AuthenticationConfigurationService.ctorParameters = () => [
212 { type: undefined, decorators: [{ type: Inject, args: [MODULE_CONFIG_TOKEN,] }] },
213 { type: Store }
214];
215/** @nocollapse */ AuthenticationConfigurationService.ngInjectableDef = defineInjectable({ factory: function AuthenticationConfigurationService_Factory() { return new AuthenticationConfigurationService(inject(MODULE_CONFIG_TOKEN), inject(Store)); }, token: AuthenticationConfigurationService, providedIn: "root" });
216
217/**
218 * @fileoverview added by tsickle
219 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
220 */
221class ProgressingStarted {
222 constructor() {
223 this.type = "[AUTHENTICATION] PROGRESSING_STARTED" /* PROGRESSING_STARTED */;
224 }
225}
226class ProgressingFinished {
227 constructor() {
228 this.type = "[AUTHENTICATION] PROGRESSING_FINISHED" /* PROGRESSING_FINISHED */;
229 }
230}
231
232/**
233 * @fileoverview added by tsickle
234 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
235 */
236/** @type {?} */
237const NEW_CAPTCHA = '[captcha] new captcha';
238class NewCaptcha {
239 constructor() {
240 this.type = NEW_CAPTCHA;
241 }
242}
243
244/**
245 * @fileoverview added by tsickle
246 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
247 */
248
249/**
250 * @fileoverview added by tsickle
251 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
252 */
253/** @type {?} */
254const COOKIE_NAME = "ngs-authentication";
255class SigninService {
256 /**
257 * @param {?} http
258 * @param {?} store
259 * @param {?} configurationService
260 * @param {?} snackBar
261 */
262 constructor(http, store, configurationService, snackBar) {
263 this.http = http;
264 this.store = store;
265 this.configurationService = configurationService;
266 this.snackBar = snackBar;
267 setTimeout(() => this.store.dispatch(new WhoAmIAction()), 300);
268 }
269 /**
270 * @param {?} model
271 * @return {?}
272 */
273 signup(model) {
274 return this.configurationService.config$.pipe(filter(config => config.endpoints.signUp != ""), take(1), switchMap(config => this.http.post(config.env[config.server] + config.endpoints.signUp, model)), map(response => {
275 /** @type {?} */
276 const user = Object.assign({}, response.Result);
277 if (user.Role) {
278 user.Roles = [user.Role];
279 }
280 return user;
281 }));
282 }
283 /**
284 * @param {?} model
285 * @return {?}
286 */
287 signin(model) {
288 return this.configurationService.config$.pipe(filter(config => config.endpoints.signIn != ""), take(1), switchMap(config => this.http.post(config.env[config.server] + config.endpoints.signIn, model)), map(this.configurationService.config.responseToUser), map((user) => {
289 if (user.Role) {
290 user.Roles = [user.Role];
291 }
292 return user;
293 }), tap(user => {
294 if (this.configurationService.config.mode == "token-base")
295 Cookie.setCookie(COOKIE_NAME, JSON.stringify(user), this.configurationService.config.token.time);
296 }), tap((user) => this.configurationService.config.afterSignin(user)));
297 }
298 /**
299 * @return {?}
300 */
301 signout() {
302 Cookie.deleteCookie(COOKIE_NAME);
303 return this.http
304 .get(this.configurationService.config.env[this.configurationService.config.server] + this.configurationService.config.endpoints.signOut)
305 .pipe(tap(() => {
306 Cookie.deleteCookie(COOKIE_NAME);
307 }));
308 }
309 /**
310 * @return {?}
311 */
312 whoAmI() {
313 debugger;
314 /** @type {?} */
315 let user = { Token: "--" };
316 if (this.configurationService.config.mode == "token-base") {
317 try {
318 user = JSON.parse(Cookie.getCookie(COOKIE_NAME));
319 }
320 catch (error) { }
321 }
322 return this.configurationService.config$.pipe(filter(config => config.endpoints.whoAmI != ""), take(1), switchMap(config => this.http.get(stringTemplate(config.env[config.server] + config.endpoints.whoAmI, { user }))));
323 }
324}
325SigninService.decorators = [
326 { type: Injectable, args: [{
327 providedIn: "root"
328 },] }
329];
330/** @nocollapse */
331SigninService.ctorParameters = () => [
332 { type: HttpClient },
333 { type: Store },
334 { type: AuthenticationConfigurationService },
335 { type: MatSnackBar }
336];
337/** @nocollapse */ SigninService.ngInjectableDef = defineInjectable({ factory: function SigninService_Factory() { return new SigninService(inject(HttpClient), inject(Store), inject(AuthenticationConfigurationService), inject(MatSnackBar$1)); }, token: SigninService, providedIn: "root" });
338
339/**
340 * @fileoverview added by tsickle
341 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
342 */
343class SigninContainerComponent {
344 /**
345 * @param {?} configurationService
346 * @param {?} store
347 */
348 constructor(configurationService, store) {
349 this.configurationService = configurationService;
350 this.store = store;
351 this.signedIn$ = new EventEmitter();
352 this.formId$ = this.configurationService.config$.map(config => config.forms.signIn);
353 }
354 /**
355 * @param {?} formValue
356 * @return {?}
357 */
358 signIn(formValue) {
359 this.store.dispatch(new Signin(formValue));
360 this.signedIn$.emit(true);
361 }
362}
363SigninContainerComponent.decorators = [
364 { type: Component, args: [{
365 template: `
366 <auth-signin
367 [formId]='(formId$ | async)'
368 (signedin)="signIn($event)"
369 ></auth-signin>
370 `
371 }] }
372];
373/** @nocollapse */
374SigninContainerComponent.ctorParameters = () => [
375 { type: AuthenticationConfigurationService },
376 { type: Store }
377];
378SigninContainerComponent.propDecorators = {
379 signedIn$: [{ type: Output }]
380};
381
382/**
383 * @fileoverview added by tsickle
384 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
385 */
386class AuthenticationContainerComponent {
387}
388AuthenticationContainerComponent.decorators = [
389 { type: Component, args: [{
390 template: `
391 <router-outlet></router-outlet>
392 `
393 }] }
394];
395
396/**
397 * @fileoverview added by tsickle
398 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
399 */
400class SignupContainerComponent {
401 /**
402 * @param {?} configurationService
403 * @param {?} store
404 * @param {?} snackBar
405 */
406 constructor(configurationService, store, snackBar) {
407 this.configurationService = configurationService;
408 this.store = store;
409 this.snackBar = snackBar;
410 this.signedUp$ = new EventEmitter();
411 this.formId$ = this.configurationService.config$.map(config => config.forms.signUp);
412 }
413 /**
414 * @param {?} formValue
415 * @return {?}
416 */
417 signup(formValue) {
418 this.configurationService.config$
419 .pipe(take(1), switchMap(config => config.signupValidator(formValue)))
420 .subscribe(validation => {
421 if (validation) {
422 this.store.dispatch(new Signup(formValue));
423 this.signedUp$.emit(true);
424 }
425 else {
426 this.snackBar.open("رمز عبور یکسان نیست", null, {
427 duration: 2222
428 });
429 }
430 });
431 }
432}
433SignupContainerComponent.decorators = [
434 { type: Component, args: [{
435 template: `
436 <auth-signup
437 [formId]='(formId$ | async)'
438 (signedup)="signup($event)"
439 ></auth-signup>
440 `
441 }] }
442];
443/** @nocollapse */
444SignupContainerComponent.ctorParameters = () => [
445 { type: AuthenticationConfigurationService },
446 { type: Store },
447 { type: MatSnackBar }
448];
449SignupContainerComponent.propDecorators = {
450 signedUp$: [{ type: Output }]
451};
452
453/**
454 * @fileoverview added by tsickle
455 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
456 */
457/** @type {?} */
458const routes = [
459 {
460 path: "auth",
461 component: AuthenticationContainerComponent,
462 children: [
463 {
464 path: "signin",
465 // canActivate: [ SigninGuard ],
466 component: SigninContainerComponent
467 },
468 {
469 path: "signup",
470 // canActivate: [ SigninGuard ],
471 component: SignupContainerComponent
472 }
473 ]
474 }
475];
476/** @type {?} */
477const AuthenticationRoutingModule = RouterModule.forChild(routes);
478
479/**
480 * @fileoverview added by tsickle
481 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
482 */
483class SigninComponent {
484 constructor() {
485 this.signedin = new EventEmitter();
486 }
487 /**
488 * @param {?} formGroup
489 * @return {?}
490 */
491 signin(formGroup) {
492 if (!formGroup.valid)
493 return;
494 this.signedin.emit(formGroup.value);
495 }
496}
497SigninComponent.decorators = [
498 { type: Component, args: [{
499 selector: "auth-signin",
500 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> -->",
501 styles: [""]
502 }] }
503];
504/** @nocollapse */
505SigninComponent.ctorParameters = () => [];
506SigninComponent.propDecorators = {
507 signedin: [{ type: Output }],
508 formId: [{ type: Input }]
509};
510
511/**
512 * @fileoverview added by tsickle
513 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
514 */
515class WithCredentialInterceptor {
516 /**
517 * @param {?} configurationService
518 */
519 constructor(configurationService) {
520 this.configurationService = configurationService;
521 }
522 /**
523 * @param {?} request
524 * @param {?} next
525 * @return {?}
526 */
527 intercept(request, next) {
528 // if (!this.configurationService.config.env.production)
529 (/** @type {?} */ (request)).withCredentials = true;
530 return next.handle(request);
531 }
532}
533WithCredentialInterceptor.decorators = [
534 { type: Injectable }
535];
536/** @nocollapse */
537WithCredentialInterceptor.ctorParameters = () => [
538 { type: AuthenticationConfigurationService }
539];
540
541/**
542 * @fileoverview added by tsickle
543 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
544 */
545class UnauthorizedInterceptor {
546 /**
547 * @param {?} router
548 * @param {?} store
549 */
550 constructor(router, store // private signinService: SigninService
551 ) {
552 this.router = router;
553 this.store = store;
554 }
555 /**
556 * @param {?} request
557 * @param {?} next
558 * @return {?}
559 */
560 intercept(request, next) {
561 return next
562 .handle(request)
563 .map((event) => {
564 if (event instanceof HttpResponse)
565 return event;
566 })
567 .catch(err => {
568 if (!(err instanceof HttpErrorResponse))
569 return throwError(err);
570 if (err.status != 401)
571 return throwError(err);
572 if (err.url.includes("logout"))
573 return throwError(err);
574 if (err.url.includes("user/account/profile"))
575 return throwError(err);
576 this.store.dispatch(new SignoutAction());
577 return throwError("Unauthorized");
578 });
579 }
580}
581UnauthorizedInterceptor.decorators = [
582 { type: Injectable }
583];
584/** @nocollapse */
585UnauthorizedInterceptor.ctorParameters = () => [
586 { type: Router },
587 { type: Store }
588];
589
590/**
591 * @fileoverview added by tsickle
592 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
593 */
594/** @type {?} */
595const initialState = {
596 loggedIn: false,
597 user: new UserModel({ Id: 1 })
598};
599/**
600 * @param {?=} state
601 * @param {?=} action
602 * @return {?}
603 */
604function UserReducer(state = initialState, action) {
605 switch (action.type) {
606 case SignInActionTypes.SIGNIN_SUCCEED: {
607 return Object.assign({}, state, { loggedIn: true, user: action.payload });
608 }
609 case SignInActionTypes.SIGNOUT: {
610 return Object.assign({}, state, { loggedIn: false, user: new UserModel() });
611 }
612 default: {
613 return state;
614 }
615 }
616}
617/** @type {?} */
618const getLoggedIn = (state) => state.loggedIn;
619/** @type {?} */
620const getUser = (state) => state.user;
621//#endregion
622
623/**
624 * @fileoverview added by tsickle
625 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
626 */
627/** @type {?} */
628const AuthenticationReducers = {
629 userStatus: UserReducer
630};
631/** @type {?} */
632const selectAuthenticationState = createFeatureSelector("authentication");
633/** @type {?} */
634const selectAuthState = createSelector(selectAuthenticationState, (state) => state.userStatus);
635/** @type {?} */
636const getLoggedIn$1 = createSelector(selectAuthState, getLoggedIn);
637/** @type {?} */
638const getUser$1 = createSelector(selectAuthState, getUser);
639// export const selectCaptchaState = createSelector(selectAuthenticationState, (state: AuthenticationState) => {
640// return state.captcha;
641// });
642// export const getCaptcha = createSelector(selectCaptchaState, captchaReducer.getCaptcha);
643
644/**
645 * @fileoverview added by tsickle
646 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
647 */
648
649/**
650 * @fileoverview added by tsickle
651 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
652 */
653class SigninEffects {
654 /**
655 * @param {?} actions$
656 * @param {?} router
657 * @param {?} signinService
658 * @param {?} configurationService
659 * @param {?} bottomSheet
660 */
661 constructor(actions$, router, signinService, configurationService, bottomSheet) {
662 this.actions$ = actions$;
663 this.router = router;
664 this.signinService = signinService;
665 this.configurationService = configurationService;
666 this.bottomSheet = bottomSheet;
667 this.whoAmI$ = this.actions$
668 .ofType(SignInActionTypes.WHO_AM_I)
669 .pipe(switchMap(() => this.signinService
670 .whoAmI()
671 .pipe(map(user => new SigninSecceed(user)), catchError(error => of(new SigninFailed(error))))));
672 this.Signin$ = this.actions$
673 .ofType(SignInActionTypes.SIGNIN)
674 .pipe(pluck("payload"), switchMap(payload => this.signinService
675 .signin(payload)
676 .pipe(map(user => new SigninSecceed(user)), catchError(error => of(new SigninFailed(error))))));
677 this.signup$ = this.actions$
678 .ofType(SignInActionTypes.SIGNUP)
679 .pipe(pluck("payload"), switchMap(payload => this.signinService
680 .signup(payload)
681 .pipe(map(user => new SignupSecceed(user)), catchError(error => of(new SignupFailed(error))))));
682 this.signupSucceed$ = this.actions$.ofType(SignInActionTypes.SIGNUP_SUCCEED).pipe(tap(() => {
683 debugger;
684 this.router.navigate(["auth/signin"]);
685 }));
686 this.SignInRequired$ = this.actions$.ofType(SignInActionTypes.SIGNIN_REQUIRED).pipe(tap((data) => {
687 /** @type {?} */
688 const signinBottomSheetRef = this.bottomSheet.open(SigninContainerComponent, {
689 panelClass: "clear-mat-card-box"
690 });
691 signinBottomSheetRef.instance.signedIn$.subscribe(() => {
692 signinBottomSheetRef.dismiss();
693 });
694 return signinBottomSheetRef;
695 }));
696 this.SigninSucceed$ = this.actions$.ofType(SignInActionTypes.SIGNIN_SUCCEED).pipe(tap((data) => {
697 if (location.pathname.indexOf("signin") > -1)
698 this.router.navigate(["/"]);
699 }));
700 this.AfterSigninFiled$ = this.actions$.ofType(SignInActionTypes.SIGNIN_FAILURE).map(() => new NewCaptcha());
701 this.DoSignout$ = this.actions$.ofType(SignInActionTypes.DO_SIGNOUT).pipe(switchMap(data => this.signinService.signout().pipe(map(() => new SignoutAction()), catchError(err => {
702 // TODO: dispatch valid action
703 debugger;
704 return of(err);
705 }))));
706 // TODO
707 // @Effect() Signout$ = this.actions$.ofType(SignInActionTypes.DO_SIGNOUT).pipe(map(() => new SignoutAction()));
708 this.redirectToLoginPage$ = this.actions$
709 .ofType(SignInActionTypes.SIGNIN_REDIRECT)
710 .pipe(tap(authed => this.router.navigate(["auth/signin"])));
711 this.redirectAfterSignout$ = this.actions$
712 .ofType(SignInActionTypes.SIGNOUT)
713 .pipe(tap(authed => this.router.navigate([this.configurationService.config$.getValue().afterSignoutRedirectTo])));
714 }
715}
716SigninEffects.decorators = [
717 { type: Injectable }
718];
719/** @nocollapse */
720SigninEffects.ctorParameters = () => [
721 { type: Actions },
722 { type: Router },
723 { type: SigninService },
724 { type: AuthenticationConfigurationService },
725 { type: MatBottomSheet }
726];
727__decorate([
728 Effect(),
729 __metadata("design:type", Object)
730], SigninEffects.prototype, "whoAmI$", void 0);
731__decorate([
732 Effect(),
733 __metadata("design:type", Object)
734], SigninEffects.prototype, "Signin$", void 0);
735__decorate([
736 Effect(),
737 __metadata("design:type", Object)
738], SigninEffects.prototype, "signup$", void 0);
739__decorate([
740 Effect({ dispatch: false }),
741 __metadata("design:type", Object)
742], SigninEffects.prototype, "signupSucceed$", void 0);
743__decorate([
744 Effect({ dispatch: false }),
745 __metadata("design:type", Object)
746], SigninEffects.prototype, "SignInRequired$", void 0);
747__decorate([
748 Effect({ dispatch: false }),
749 __metadata("design:type", Object)
750], SigninEffects.prototype, "SigninSucceed$", void 0);
751__decorate([
752 Effect(),
753 __metadata("design:type", Object)
754], SigninEffects.prototype, "AfterSigninFiled$", void 0);
755__decorate([
756 Effect(),
757 __metadata("design:type", Object)
758], SigninEffects.prototype, "DoSignout$", void 0);
759__decorate([
760 Effect({ dispatch: false }),
761 __metadata("design:type", Object)
762], SigninEffects.prototype, "redirectToLoginPage$", void 0);
763__decorate([
764 Effect({ dispatch: false }),
765 __metadata("design:type", Object)
766], SigninEffects.prototype, "redirectAfterSignout$", void 0);
767
768/**
769 * @fileoverview added by tsickle
770 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
771 */
772class AuthenticationEffects {
773 /**
774 * @param {?} actions$
775 * @param {?} router
776 */
777 constructor(actions$, router) {
778 this.actions$ = actions$;
779 this.router = router;
780 this.dispachProgressingStarted$ = this.actions$
781 .ofType(SignInActionTypes.SIGNIN)
782 .pipe(map(() => new ProgressingStarted()));
783 this.dispachProgressingFinished$ = this.actions$
784 .ofType(SignInActionTypes.SIGNIN_FAILURE, SignInActionTypes.SIGNIN_SUCCEED)
785 .pipe(map(() => new ProgressingFinished()));
786 }
787}
788AuthenticationEffects.decorators = [
789 { type: Injectable }
790];
791/** @nocollapse */
792AuthenticationEffects.ctorParameters = () => [
793 { type: Actions },
794 { type: Router }
795];
796__decorate([
797 Effect(),
798 __metadata("design:type", Object)
799], AuthenticationEffects.prototype, "dispachProgressingStarted$", void 0);
800__decorate([
801 Effect(),
802 __metadata("design:type", Object)
803], AuthenticationEffects.prototype, "dispachProgressingFinished$", void 0);
804
805/**
806 * @fileoverview added by tsickle
807 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
808 */
809class SignupComponent {
810 constructor() {
811 this.signedup = new EventEmitter();
812 }
813 /**
814 * @param {?} formGroup
815 * @return {?}
816 */
817 signup(formGroup) {
818 if (!formGroup.valid)
819 return;
820 this.signedup.emit(formGroup.value);
821 }
822}
823SignupComponent.decorators = [
824 { type: Component, args: [{
825 selector: "auth-signup",
826 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> -->",
827 styles: [""]
828 }] }
829];
830/** @nocollapse */
831SignupComponent.ctorParameters = () => [];
832SignupComponent.propDecorators = {
833 signedup: [{ type: Output }],
834 formId: [{ type: Input }]
835};
836
837/**
838 * @fileoverview added by tsickle
839 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
840 */
841class SigninGuard {
842 /**
843 * @param {?} store
844 */
845 constructor(store) {
846 this.store = store;
847 }
848 /**
849 * @param {?} route
850 * @param {?} state
851 * @return {?}
852 */
853 canActivate(route, state) {
854 return this.store.select(getLoggedIn$1).take(1).map(authed => !authed);
855 }
856}
857SigninGuard.decorators = [
858 { type: Injectable }
859];
860/** @nocollapse */
861SigninGuard.ctorParameters = () => [
862 { type: Store }
863];
864
865/**
866 * @fileoverview added by tsickle
867 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
868 */
869class NgsAuthenticationModule {
870 /**
871 * @param {?=} config
872 * @return {?}
873 */
874 static forRoot(config = /** @type {?} */ ({})) {
875 return {
876 ngModule: RootNgsAuthenticationModule,
877 providers: [
878 { provide: MODULE_CONFIG_TOKEN, useValue: config },
879 {
880 provide: HTTP_INTERCEPTORS,
881 useClass: UnauthorizedInterceptor,
882 multi: true
883 },
884 {
885 provide: HTTP_INTERCEPTORS,
886 useClass: WithCredentialInterceptor,
887 multi: true
888 },
889 SigninService
890 ]
891 };
892 }
893}
894NgsAuthenticationModule.decorators = [
895 { type: NgModule, args: [{
896 imports: [
897 CommonModule,
898 RouterModule,
899 FormsModule,
900 HttpClientModule,
901 FlexLayoutModule,
902 MatIconModule,
903 MatButtonModule,
904 MatCardModule,
905 MatSnackBarModule,
906 MatSidenavModule,
907 MatExpansionModule,
908 MatSelectModule,
909 MatBottomSheetModule,
910 MatFormFieldModule,
911 MatListModule,
912 MatMenuModule,
913 MatRadioModule,
914 MatInputModule,
915 MatToolbarModule,
916 MatDatepickerModule,
917 MatProgressBarModule,
918 BrowserAnimationsModule,
919 ReactiveFormsModule,
920 FormsModule,
921 NgsFormModule
922 ],
923 declarations: [
924 SigninContainerComponent,
925 SigninComponent,
926 AuthenticationContainerComponent,
927 SignupContainerComponent,
928 SignupComponent
929 ],
930 entryComponents: [SigninContainerComponent],
931 providers: [SigninGuard],
932 exports: []
933 },] }
934];
935class RootNgsAuthenticationModule {
936}
937RootNgsAuthenticationModule.decorators = [
938 { type: NgModule, args: [{
939 imports: [
940 StoreModule.forFeature("authentication", AuthenticationReducers),
941 EffectsModule.forFeature([SigninEffects, AuthenticationEffects]),
942 AuthenticationRoutingModule,
943 NgsAuthenticationModule
944 ]
945 },] }
946];
947
948/**
949 * @fileoverview added by tsickle
950 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
951 */
952
953/**
954 * @fileoverview added by tsickle
955 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
956 */
957
958export { UserModel, SignInActionTypes, DoSignoutAction, SigninRequiredAction, SigninService, SigninContainerComponent, NgsAuthenticationModule, getUser$1 as getUser, AuthenticationRoutingModule as ɵr, MODULE_CONFIG_TOKEN as ɵa, RootNgsAuthenticationModule as ɵb, SigninComponent as ɵi, SignupComponent as ɵl, AuthenticationEffects as ɵq, SigninEffects as ɵp, UnauthorizedInterceptor as ɵs, WithCredentialInterceptor as ɵt, AuthenticationReducers as ɵc, selectAuthState as ɵe, selectAuthenticationState as ɵd, UserReducer as ɵn, getUser as ɵo, SigninGuard as ɵm, AuthenticationConfigurationService as ɵh, AuthenticationContainerComponent as ɵj, SignupContainerComponent as ɵk };
959
960//# sourceMappingURL=soushians-authentication.js.map
\No newline at end of file