자동 로그인 && 네트워크 절체시 로직 변경.

1. retry 시간 10분 > 1분. (3초간격)
2. 최종 실패시 앱종료 > 로그인페이지로.
This commit is contained in:
leejinho 2020-03-25 11:40:37 +09:00
parent 6d5073566b
commit 9a98298aa1
5 changed files with 123 additions and 27 deletions

View File

@ -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)"

View File

@ -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;

View File

@ -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<AppUserInfo>(
KEY_APP_USER_INFO,
appUserInfo,
environment.customConfig.appKey
);
// Logout reason setting.
this.sessionStorageService.set<LogoutInfo>(
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
);
}
}
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();
// 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<AppUserInfo>(
KEY_APP_USER_INFO,
appUserInfo,
environment.customConfig.appKey
);
// Logout reason setting.
this.sessionStorageService.set<LogoutInfo>(
KEY_LOGOUT_INFO,
{
personLogout: true,
autoLogin: {
state: 'NETWORK_FAIL'
}
});
} as LogoutInfo
);
}
}
this.router.navigateByUrl('/account/login');
console.log('not retry');
return of(webLoginFailure({ error }));

View File

@ -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;
};
}

View File

@ -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,