From 9a98298aa15bebdf44006988ed9a37dda13eb4a5 Mon Sep 17 00:00:00 2001 From: leejinho Date: Wed, 25 Mar 2020 11:40:37 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20&&=20=EB=84=A4=ED=8A=B8=EC=9B=8C=ED=81=AC=20?= =?UTF-8?q?=EC=A0=88=EC=B2=B4=EC=8B=9C=20=EB=A1=9C=EC=A7=81=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD.=201.=20retry=20=EC=8B=9C=EA=B0=84=2010=EB=B6=84=20>?= =?UTF-8?q?=201=EB=B6=84.=20(3=EC=B4=88=EA=B0=84=EA=B2=A9)=202.=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EC=8B=A4=ED=8C=A8=EC=8B=9C=20=EC=95=B1?= =?UTF-8?q?=EC=A2=85=EB=A3=8C=20>=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EB=A1=9C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/login.page.component.html | 3 +- .../components/login.page.component.ts | 57 +++++++++++++++ .../store/account/authentication/effects.ts | 70 +++++++++++++------ .../src/app/types/logout-info.type.ts | 15 +++- .../src/lib/components/login.component.ts | 5 ++ 5 files changed, 123 insertions(+), 27 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.html b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.html index 77a1529d..88181d91 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.html +++ b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.html @@ -60,8 +60,9 @@ [loginBtnText]="loginBtnText" [companyCode]="appUserInfo?.companyCode" [loginId]="appUserInfo?.loginId" + [loginPw]="loginPw" [rememberMe]="appUserInfo?.rememberMe" - [autoLogin]="appUserInfo?.settings?.general?.autoLogin" + [autoLogin]="autologin" [useRememberMe]="useRememberMe" [useAutoLogin]="useAutoLogin" (login)="onLogin($event)" diff --git a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts index 16c265c7..162ef502 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts +++ b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts @@ -63,6 +63,8 @@ export class LoginPageComponent implements OnInit, OnDestroy { waitingTime: number; appUserInfo: AppUserInfo; + loginPw: string; + autologin: boolean; useRememberMe: boolean; useAutoLogin: boolean; @@ -103,6 +105,9 @@ export class LoginPageComponent implements OnInit, OnDestroy { KEY_APP_USER_INFO, environment.customConfig.appKey ); + if (!!this.appUserInfo) { + this.autologin = this.appUserInfo.settings.general.autoLogin || false; + } this.rotateInfomationIndex = new Date().getTime() % this.rotateInfomation.length; @@ -218,6 +223,56 @@ export class LoginPageComponent implements OnInit, OnDestroy { this.nativeService.idleStateStop(); } + /** CASE :: 자동로그인 실패 (비밀번호 변경에 따른 실패, 네트워크 절체) */ + if (!!personLogout && !!personLogout.autoLogin) { + switch (personLogout.autoLogin.state) { + case 'IDPW_FAIL': + { + this.ngZone.run(() => { + this.dialogService.open< + AlertDialogComponent, + AlertDialogData, + AlertDialogResult + >(AlertDialogComponent, { + width: '360px', + data: { + title: '', + html: this.translateService.instant( + 'accounts.errors.loginFailedIdPw' + ) + } + }); + }); + } + break; + case 'NETWORK_FAIL': + { + this.loginPw = this.appUserInfo.loginPw; + this.autologin = true; + + this.ngZone.run(() => { + this.dialogService.open< + AlertDialogComponent, + AlertDialogData, + AlertDialogResult + >(AlertDialogComponent, { + width: '360px', + data: { + title: this.translateService.instant( + 'accounts.errors.loginFailed' + ), + html: this.translateService.instant( + 'accounts.errors.networkFailedAndRetry' + ) + } + }); + }); + } + break; + } + } + + /** CASE :: 중복 로그인, Remote 로그아웃 */ if (!!personLogout && !!personLogout.reasonCode) { let msg = this.translateService.instant('accounts.results.doLogout'); switch (personLogout.reasonCode) { @@ -300,6 +355,8 @@ export class LoginPageComponent implements OnInit, OnDestroy { autoLogin: boolean; notValid: () => void; }) { + this.sessionStorageService.remove(KEY_LOGOUT_INFO); + this.loginBtnEnable = false; setTimeout(() => { this.loginBtnEnable = true; 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 6189e44f..116a3b19 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 @@ -94,7 +94,7 @@ import { StatusCode } from '@ucap-webmessenger/api'; export class Effects { retryCount = 0; retryInterval = 3000; // ms - maxRetryCount = (10 * 60 * 1000) / this.retryInterval; // 200 count due to 10 min. + maxRetryCount = (1 * 60 * 1000) / this.retryInterval; // 20 count due to 1 min. webLogin$ = createEffect( () => this.actions$.pipe( @@ -119,8 +119,29 @@ export class Effects { if ('success' !== res.status.toLowerCase()) { if (!!params.autoLogin) { // auto login Failure. - this.store.dispatch(increaseLoginFailCount({})); - this.localStorageService.remove(KEY_APP_USER_INFO); + // clear setting for autologin. + // this.localStorageService.remove(KEY_APP_USER_INFO); + const appUserInfo = this.localStorageService.encGet< + AppUserInfo + >(KEY_APP_USER_INFO, environment.customConfig.appKey); + appUserInfo.settings.general.autoLogin = false; + this.localStorageService.encSet( + KEY_APP_USER_INFO, + appUserInfo, + environment.customConfig.appKey + ); + + // Logout reason setting. + this.sessionStorageService.set( + KEY_LOGOUT_INFO, + { + personLogout: true, + autoLogin: { + state: 'IDPW_FAIL' + } + } as LogoutInfo + ); + this.router.navigateByUrl('/account/login'); } else { this.store.dispatch(increaseLoginFailCount({})); @@ -156,29 +177,32 @@ export class Effects { this.retryCount, this.maxRetryCount ); + + // clear setting for autologin. + const appUserInfo = this.localStorageService.encGet< + AppUserInfo + >(KEY_APP_USER_INFO, environment.customConfig.appKey); + appUserInfo.settings.general.autoLogin = false; + this.localStorageService.encSet( + KEY_APP_USER_INFO, + appUserInfo, + environment.customConfig.appKey + ); + + // Logout reason setting. + this.sessionStorageService.set( + KEY_LOGOUT_INFO, + { + personLogout: true, + autoLogin: { + state: 'NETWORK_FAIL' + } + } as LogoutInfo + ); } } - this.ngZone.run(async () => { - const result = await this.dialogService.open< - AlertDialogComponent, - AlertDialogData, - AlertDialogResult - >(AlertDialogComponent, { - width: '360px', - data: { - title: this.translateService.instant( - 'accounts.errors.loginFailed' - ), - html: this.translateService.instant( - 'accounts.errors.networkFailedAndExit' - ) - } - }); - if (!!result) { - this.nativeService.appExit(); - } - }); + this.router.navigateByUrl('/account/login'); console.log('not retry'); return of(webLoginFailure({ error })); diff --git a/projects/ucap-webmessenger-app/src/app/types/logout-info.type.ts b/projects/ucap-webmessenger-app/src/app/types/logout-info.type.ts index b187b95f..b2cb68ab 100644 --- a/projects/ucap-webmessenger-app/src/app/types/logout-info.type.ts +++ b/projects/ucap-webmessenger-app/src/app/types/logout-info.type.ts @@ -2,8 +2,17 @@ export const KEY_LOGOUT_INFO = 'ucap::LOGOUT_INFO'; export interface LogoutInfo { personLogout: boolean; + + /** 중복로그인, Remote 로그아웃 시에 사용. */ reasonCode?: number; - ip?: string; - mac?: string; - forceType?: string; + ip?: string; // 중복로그인시 사용. + mac?: string; // 중복로그인시 사용. + forceType?: string; // remote 로그아웃 시 사용. + + /** 자동로그인 실패시. */ + autoLogin?: { + state: string; + id?: string; + pw?: string; + }; } diff --git a/projects/ucap-webmessenger-ui-account/src/lib/components/login.component.ts b/projects/ucap-webmessenger-ui-account/src/lib/components/login.component.ts index fef9f5de..12350319 100644 --- a/projects/ucap-webmessenger-ui-account/src/lib/components/login.component.ts +++ b/projects/ucap-webmessenger-ui-account/src/lib/components/login.component.ts @@ -39,6 +39,8 @@ export class LoginComponent implements OnInit { @Input() loginId: string; @Input() + loginPw?: string; + @Input() rememberMe: boolean; @Input() autoLogin: boolean; @@ -85,6 +87,9 @@ export class LoginComponent implements OnInit { } const loginPwValidators: ValidatorFn[] = [Validators.required]; this.loginPwFormControl.setValidators(loginPwValidators); + if (!!this.loginPw) { + this.loginPwFormControl.setValue(this.loginPw); + } this.loginForm = this.formBuilder.group({ companyCodeFormControl: this.companyCodeFormControl,