From 2ceec93b366710aca684cccc6a6ab321e089757f Mon Sep 17 00:00:00 2001 From: leejinho Date: Wed, 18 Mar 2020 10:28:08 +0900 Subject: [PATCH] =?UTF-8?q?bugfix=20:=20=EC=9E=90=EB=8F=99=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=EC=8B=9C=20=EC=98=A4=EB=A5=98=EB=B0=9C?= =?UTF-8?q?=EC=83=9D=ED=95=98=EB=A9=B4=20=EB=A1=9C=EB=94=A9=EC=A4=91?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=ED=91=9C=EC=8B=9C=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EB=B3=B4=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/account/authentication/effects.ts | 80 +++++++++++-------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts b/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts index 3d00ab0b..66b171f7 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/authentication/effects.ts @@ -87,41 +87,51 @@ import { @Injectable() export class Effects { - webLogin$ = createEffect(() => - this.actions$.pipe( - ofType(webLogin), - map(action => action), - exhaustMap( - (params: { - loginInfo: LoginInfo; - rememberMe: boolean; - autoLogin: boolean; - }) => - this.piService - .login2({ - loginId: params.loginInfo.loginId, - loginPw: params.loginInfo.loginPw, - companyCode: params.loginInfo.companyCode - }) - .pipe( - map((res: Login2Response) => { - if ('success' !== res.status.toLowerCase()) { - this.store.dispatch(increaseLoginFailCount({})); - return webLoginFailure({ error: 'Failed' }); - } else { - this.store.dispatch(initialLoginFailCount({})); - return webLoginSuccess({ - loginInfo: params.loginInfo, - rememberMe: params.rememberMe, - autoLogin: params.autoLogin, - login2Response: res - }); - } - }), - catchError(error => of(webLoginFailure({ error }))) - ) - ) - ) + webLogin$ = createEffect( + () => + this.actions$.pipe( + ofType(webLogin), + map(action => action), + exhaustMap( + (params: { + loginInfo: LoginInfo; + rememberMe: boolean; + autoLogin: boolean; + }) => + this.piService + .login2({ + loginId: params.loginInfo.loginId, + loginPw: params.loginInfo.loginPw, + companyCode: params.loginInfo.companyCode + }) + .pipe( + map((res: Login2Response) => { + if ('success' !== res.status.toLowerCase()) { + if (!!params.autoLogin) { + // auto login Failure. + this.localStorageService.remove(KEY_APP_USER_INFO); + this.router.navigateByUrl('/account/login'); + } else { + this.store.dispatch(increaseLoginFailCount({})); + this.store.dispatch(webLoginFailure({ error: 'Failed' })); + } + } else { + this.store.dispatch(initialLoginFailCount({})); + this.store.dispatch( + webLoginSuccess({ + loginInfo: params.loginInfo, + rememberMe: params.rememberMe, + autoLogin: params.autoLogin, + login2Response: res + }) + ); + } + }), + catchError(error => of(webLoginFailure({ error }))) + ) + ) + ), + { dispatch: false } ); webLoginSuccess$ = createEffect(