bugfix : 자동로그인시 오류발생하면 로딩중으로 표시되는 문제 보완

This commit is contained in:
leejinho 2020-03-18 10:28:08 +09:00
parent 93bcfa9cb7
commit 2ceec93b36

View File

@ -87,41 +87,51 @@ import {
@Injectable() @Injectable()
export class Effects { export class Effects {
webLogin$ = createEffect(() => webLogin$ = createEffect(
this.actions$.pipe( () =>
ofType(webLogin), this.actions$.pipe(
map(action => action), ofType(webLogin),
exhaustMap( map(action => action),
(params: { exhaustMap(
loginInfo: LoginInfo; (params: {
rememberMe: boolean; loginInfo: LoginInfo;
autoLogin: boolean; rememberMe: boolean;
}) => autoLogin: boolean;
this.piService }) =>
.login2({ this.piService
loginId: params.loginInfo.loginId, .login2({
loginPw: params.loginInfo.loginPw, loginId: params.loginInfo.loginId,
companyCode: params.loginInfo.companyCode loginPw: params.loginInfo.loginPw,
}) companyCode: params.loginInfo.companyCode
.pipe( })
map((res: Login2Response) => { .pipe(
if ('success' !== res.status.toLowerCase()) { map((res: Login2Response) => {
this.store.dispatch(increaseLoginFailCount({})); if ('success' !== res.status.toLowerCase()) {
return webLoginFailure({ error: 'Failed' }); if (!!params.autoLogin) {
} else { // auto login Failure.
this.store.dispatch(initialLoginFailCount({})); this.localStorageService.remove(KEY_APP_USER_INFO);
return webLoginSuccess({ this.router.navigateByUrl('/account/login');
loginInfo: params.loginInfo, } else {
rememberMe: params.rememberMe, this.store.dispatch(increaseLoginFailCount({}));
autoLogin: params.autoLogin, this.store.dispatch(webLoginFailure({ error: 'Failed' }));
login2Response: res }
}); } else {
} this.store.dispatch(initialLoginFailCount({}));
}), this.store.dispatch(
catchError(error => of(webLoginFailure({ error }))) webLoginSuccess({
) loginInfo: params.loginInfo,
) rememberMe: params.rememberMe,
) autoLogin: params.autoLogin,
login2Response: res
})
);
}
}),
catchError(error => of(webLoginFailure({ error })))
)
)
),
{ dispatch: false }
); );
webLoginSuccess$ = createEffect( webLoginSuccess$ = createEffect(