2019-11-19 18:43:49 +09:00
|
|
|
import { Injectable, Inject, NgZone } from '@angular/core';
|
2019-09-18 15:02:21 +09:00
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
2019-11-13 15:28:33 +09:00
|
|
|
import { of, Observable } from 'rxjs';
|
2019-10-02 14:34:17 +09:00
|
|
|
import { catchError, exhaustMap, map, tap, switchMap } from 'rxjs/operators';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-09-27 12:53:21 +09:00
|
|
|
import { Actions, ofType, createEffect } from '@ngrx/effects';
|
|
|
|
|
2019-10-04 10:19:55 +09:00
|
|
|
import {
|
|
|
|
PiService,
|
|
|
|
Login2Response,
|
2019-11-14 14:19:59 +09:00
|
|
|
UserTermsActionResponse
|
2019-10-04 10:19:55 +09:00
|
|
|
} from '@ucap-webmessenger/pi';
|
2019-09-19 17:03:39 +09:00
|
|
|
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
|
|
|
import {
|
|
|
|
DialogService,
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
2019-11-29 15:09:47 +09:00
|
|
|
ConfirmDialogResult,
|
2019-11-29 16:08:24 +09:00
|
|
|
SnackBarService,
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
2019-09-19 17:03:39 +09:00
|
|
|
} from '@ucap-webmessenger/ui';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
|
|
|
import {
|
|
|
|
loginRedirect,
|
2019-09-19 17:03:39 +09:00
|
|
|
logout,
|
|
|
|
logoutConfirmation,
|
2019-09-24 09:23:30 +09:00
|
|
|
logoutConfirmationDismiss,
|
|
|
|
webLogin,
|
|
|
|
webLoginSuccess,
|
2019-10-04 10:19:55 +09:00
|
|
|
webLoginFailure,
|
|
|
|
postLogin,
|
|
|
|
privacyAgree,
|
|
|
|
privacyDisagree,
|
|
|
|
privacyAgreeFailure,
|
|
|
|
privacyAgreeSuccess,
|
2019-11-14 14:19:59 +09:00
|
|
|
increaseLoginFailCount,
|
2019-11-19 18:43:49 +09:00
|
|
|
initialLoginFailCount,
|
2019-11-29 14:26:59 +09:00
|
|
|
logoutInitialize,
|
|
|
|
userPasswordSet,
|
|
|
|
userPasswordSetSuccess,
|
2020-01-13 14:54:25 +09:00
|
|
|
userPasswordSetFailure,
|
|
|
|
infoUser,
|
|
|
|
infoUserSuccess,
|
|
|
|
infoUserFailure
|
2019-09-18 15:02:21 +09:00
|
|
|
} from './actions';
|
2019-10-04 10:19:55 +09:00
|
|
|
import {
|
|
|
|
LoginInfo,
|
|
|
|
KEY_LOGIN_INFO,
|
|
|
|
EnvironmentsInfo,
|
2019-12-17 17:24:06 +09:00
|
|
|
KEY_ENVIRONMENTS_INFO,
|
2020-01-03 17:39:44 +09:00
|
|
|
KEY_URL_INFO,
|
|
|
|
LogoutInfo,
|
|
|
|
KEY_LOGOUT_INFO
|
2019-10-04 10:19:55 +09:00
|
|
|
} from '@app/types';
|
|
|
|
import { AppAuthenticationService } from '@app/services/authentication.service';
|
2019-09-27 12:53:21 +09:00
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-10-04 10:19:55 +09:00
|
|
|
import { Store } from '@ngrx/store';
|
2019-12-19 08:49:06 +09:00
|
|
|
import {
|
|
|
|
SessionStorageService,
|
|
|
|
LocalStorageService
|
|
|
|
} from '@ucap-webmessenger/web-storage';
|
2019-11-28 18:12:20 +09:00
|
|
|
|
2019-11-25 10:47:44 +09:00
|
|
|
import {
|
|
|
|
AuthenticationProtocolService,
|
|
|
|
LoginResponse
|
|
|
|
} from '@ucap-webmessenger/protocol-authentication';
|
|
|
|
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
|
2019-11-28 13:19:19 +09:00
|
|
|
import { ProtocolService } from '@ucap-webmessenger/protocol';
|
2019-09-18 15:02:21 +09:00
|
|
|
|
2019-11-28 14:02:07 +09:00
|
|
|
import { environment } from '../../../../environments/environment';
|
2020-01-08 12:30:39 +09:00
|
|
|
|
2019-11-29 14:26:59 +09:00
|
|
|
import {
|
|
|
|
ServiceProtocolService,
|
|
|
|
UserPasswordSetResponse
|
|
|
|
} from '@ucap-webmessenger/protocol-service';
|
2020-03-20 13:57:50 +09:00
|
|
|
import {
|
|
|
|
DaesangUrlInfoResponse,
|
|
|
|
ExternalApiService,
|
|
|
|
CompanyListRequest
|
|
|
|
} from '@ucap-webmessenger/api-external';
|
2019-12-19 08:49:06 +09:00
|
|
|
import { AppUserInfo, KEY_APP_USER_INFO } from '@app/types/app-user-info.type';
|
2020-01-03 11:05:17 +09:00
|
|
|
import { DaesangCipherService, WebLinkType } from '@ucap-webmessenger/daesang';
|
2020-01-08 12:30:39 +09:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2020-01-13 14:54:25 +09:00
|
|
|
import {
|
|
|
|
InfoProtocolService,
|
|
|
|
UserResponse
|
|
|
|
} from '@ucap-webmessenger/protocol-info';
|
2020-03-20 13:57:50 +09:00
|
|
|
import { StatusCode } from '@ucap-webmessenger/api';
|
2019-11-28 14:02:07 +09:00
|
|
|
|
2019-09-18 15:02:21 +09:00
|
|
|
@Injectable()
|
|
|
|
export class Effects {
|
2020-03-20 13:57:50 +09:00
|
|
|
retryCount = 0;
|
|
|
|
retryInterval = 3000; // ms
|
|
|
|
maxRetryCount = (10 * 60 * 1000) / this.retryInterval; // 200 count due to 10 min.
|
2020-03-18 10:28:08 +09:00
|
|
|
webLogin$ = createEffect(
|
|
|
|
() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(webLogin),
|
|
|
|
map(action => action),
|
|
|
|
exhaustMap(
|
|
|
|
(params: {
|
|
|
|
loginInfo: LoginInfo;
|
|
|
|
rememberMe: boolean;
|
|
|
|
autoLogin: boolean;
|
2020-03-20 13:57:50 +09:00
|
|
|
}) => {
|
|
|
|
const selfParam = params;
|
|
|
|
|
|
|
|
return this.piService
|
2020-03-18 10:28:08 +09:00
|
|
|
.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.
|
2020-03-20 13:57:50 +09:00
|
|
|
this.store.dispatch(increaseLoginFailCount({}));
|
2020-03-18 10:28:08 +09:00
|
|
|
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
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}),
|
2020-03-20 13:57:50 +09:00
|
|
|
catchError(async error => {
|
|
|
|
if (!!selfParam.autoLogin) {
|
|
|
|
if (this.maxRetryCount > this.retryCount) {
|
|
|
|
this.store.dispatch(logoutInitialize());
|
|
|
|
setTimeout(() => {
|
|
|
|
// this.store.dispatch(webLogin(selfParam));
|
|
|
|
this.router.navigateByUrl('/account/login');
|
|
|
|
}, this.retryInterval);
|
|
|
|
|
|
|
|
this.retryCount++;
|
|
|
|
console.log('retry', this.retryCount, this.maxRetryCount);
|
|
|
|
return of(webLoginFailure({ error }));
|
|
|
|
} else {
|
|
|
|
console.log(
|
|
|
|
'retry End',
|
|
|
|
this.retryCount,
|
|
|
|
this.maxRetryCount
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('not retry');
|
|
|
|
return of(webLoginFailure({ error }));
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2020-03-18 10:28:08 +09:00
|
|
|
)
|
|
|
|
),
|
|
|
|
{ dispatch: false }
|
2019-09-18 15:02:21 +09:00
|
|
|
);
|
|
|
|
|
2019-09-24 09:23:30 +09:00
|
|
|
webLoginSuccess$ = createEffect(
|
2019-09-19 14:15:43 +09:00
|
|
|
() =>
|
|
|
|
this.actions$.pipe(
|
2019-09-24 09:23:30 +09:00
|
|
|
ofType(webLoginSuccess),
|
2020-01-23 14:15:08 +09:00
|
|
|
tap(params => {
|
|
|
|
this.nativeService.checkForUpdates(params.login2Response.version);
|
|
|
|
this.appAuthenticationService.login(
|
|
|
|
params.loginInfo,
|
|
|
|
params.rememberMe,
|
|
|
|
params.autoLogin
|
|
|
|
);
|
|
|
|
this.router.navigate(['/messenger']);
|
|
|
|
})
|
2019-09-19 14:15:43 +09:00
|
|
|
),
|
|
|
|
{ dispatch: false }
|
2019-09-18 15:02:21 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
loginRedirect$ = createEffect(
|
|
|
|
() =>
|
|
|
|
this.actions$.pipe(
|
2019-09-19 17:03:39 +09:00
|
|
|
ofType(loginRedirect),
|
2019-09-18 15:02:21 +09:00
|
|
|
tap(authed => {
|
2019-11-28 13:19:19 +09:00
|
|
|
// this.ngZone.run(() => {
|
|
|
|
// location.href = this.router.parseUrl('/account/login').toString();
|
2019-12-20 11:07:41 +09:00
|
|
|
this.protocolService.disconnect();
|
2019-11-28 15:48:36 +09:00
|
|
|
this.router.navigate(['/account/login']);
|
2019-11-28 13:19:19 +09:00
|
|
|
this.appAuthenticationService.logout();
|
|
|
|
this.store.dispatch(logoutInitialize());
|
|
|
|
// });
|
2019-09-18 15:02:21 +09:00
|
|
|
})
|
|
|
|
),
|
|
|
|
{ dispatch: false }
|
|
|
|
);
|
|
|
|
|
2019-11-19 18:43:49 +09:00
|
|
|
logout$ = createEffect(
|
|
|
|
() => {
|
|
|
|
return this.actions$.pipe(
|
|
|
|
ofType(logout),
|
|
|
|
switchMap(action => {
|
|
|
|
return this.authenticationProtocolService.logout({}).pipe(
|
|
|
|
map(res => {
|
2020-01-03 17:39:44 +09:00
|
|
|
this.sessionStorageService.set<LogoutInfo>(KEY_LOGOUT_INFO, {
|
|
|
|
personLogout: true
|
|
|
|
} as LogoutInfo);
|
|
|
|
|
2019-11-19 18:43:49 +09:00
|
|
|
this.store.dispatch(loginRedirect());
|
|
|
|
}),
|
|
|
|
catchError(error => of(error))
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
{ dispatch: false }
|
2019-09-19 17:03:39 +09:00
|
|
|
);
|
|
|
|
|
|
|
|
logoutConfirmation$ = createEffect(() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(logoutConfirmation),
|
|
|
|
exhaustMap(async () => {
|
2019-11-25 10:47:44 +09:00
|
|
|
const loginRes = this.sessionStorageService.get<LoginResponse>(
|
|
|
|
KEY_LOGIN_RES_INFO
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!!loginRes && loginRes.userSeq) {
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
|
|
|
data: {
|
2020-01-08 12:30:39 +09:00
|
|
|
title: this.translateService.instant('accounts.logout'),
|
|
|
|
message: this.translateService.instant('accounts.confirmLogout')
|
2019-11-25 10:47:44 +09:00
|
|
|
}
|
|
|
|
});
|
2019-09-19 17:03:39 +09:00
|
|
|
|
2019-12-17 08:55:35 +09:00
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2019-11-25 10:47:44 +09:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-19 17:03:39 +09:00
|
|
|
}),
|
|
|
|
map(result => (result ? logout() : logoutConfirmationDismiss()))
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-10-04 10:19:55 +09:00
|
|
|
postLogin$ = createEffect(
|
|
|
|
() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(postLogin),
|
|
|
|
map(action => action.loginRes),
|
|
|
|
tap(async loginRes => {
|
|
|
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
|
|
|
KEY_LOGIN_INFO
|
|
|
|
);
|
|
|
|
const environmentsInfo = this.sessionStorageService.get<
|
|
|
|
EnvironmentsInfo
|
|
|
|
>(KEY_ENVIRONMENTS_INFO);
|
|
|
|
|
2019-11-28 14:02:07 +09:00
|
|
|
if (
|
|
|
|
environment.productConfig.authentication
|
|
|
|
.usePrivateInformationAgree &&
|
|
|
|
!loginRes.privateInformationAgree
|
|
|
|
) {
|
2019-10-04 10:19:55 +09:00
|
|
|
const privacyTotalUrl = this.piService.privacyTotalUrl({
|
|
|
|
companyCode: loginInfo.companyCode,
|
|
|
|
userSeq: loginRes.userSeq,
|
|
|
|
token: loginRes.tokenString,
|
|
|
|
deviceType: environmentsInfo.deviceType,
|
|
|
|
localeCode: loginInfo.localeCode,
|
2019-11-14 14:19:59 +09:00
|
|
|
textOnly: 'true'
|
2019-10-04 10:19:55 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
|
|
|
width: '100%',
|
|
|
|
height: '500px',
|
|
|
|
disableClose: true,
|
|
|
|
data: {
|
2020-01-08 12:30:39 +09:00
|
|
|
title: this.translateService.instant(
|
|
|
|
'accounts.consentOfPrivacy'
|
|
|
|
),
|
2019-11-28 13:19:19 +09:00
|
|
|
html: `<iframe id="ifm_privacy" src="${privacyTotalUrl}" style="width: 100%;height: 300px;" />`
|
2019-11-14 14:19:59 +09:00
|
|
|
}
|
2019-10-04 10:19:55 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
if (result.choice) {
|
|
|
|
this.store.dispatch(privacyAgree({ loginRes }));
|
|
|
|
} else {
|
|
|
|
this.store.dispatch(privacyDisagree());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-20 11:07:41 +09:00
|
|
|
if (!!loginInfo.initPw) {
|
2019-11-28 15:48:36 +09:00
|
|
|
this.store.dispatch(logout());
|
|
|
|
|
|
|
|
const passwordInitStep1Url = this.piService.passwordInitStep1Url({
|
|
|
|
localeCode: loginInfo.localeCode
|
|
|
|
});
|
|
|
|
|
2019-10-04 10:19:55 +09:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
|
|
|
width: '100%',
|
|
|
|
height: '500px',
|
|
|
|
disableClose: true,
|
|
|
|
data: {
|
2020-01-08 12:30:39 +09:00
|
|
|
title: this.translateService.instant('accounts.resetPassword'),
|
2019-11-28 15:48:36 +09:00
|
|
|
html: `<iframe id="ifm_privacy" src="${passwordInitStep1Url}" style="width: 100%;height: 300px;" />`
|
2019-11-14 14:19:59 +09:00
|
|
|
}
|
2019-10-04 10:19:55 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
if (result.choice) {
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2019-11-28 15:48:36 +09:00
|
|
|
|
2019-12-03 14:30:41 +09:00
|
|
|
if (!loginRes.passwordValid) {
|
2019-12-17 17:24:06 +09:00
|
|
|
// [Daesang]
|
|
|
|
const urlInfo: DaesangUrlInfoResponse = this.sessionStorageService.get<
|
|
|
|
DaesangUrlInfoResponse
|
|
|
|
>(KEY_URL_INFO);
|
|
|
|
|
|
|
|
await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
2019-11-29 14:26:59 +09:00
|
|
|
data: {
|
2020-01-08 12:30:39 +09:00
|
|
|
title: this.translateService.instant(
|
|
|
|
'accounts.passwordExpired'
|
|
|
|
),
|
|
|
|
html: this.translateService.instant(
|
|
|
|
'accounts.descriptionOfPasswordExpired'
|
|
|
|
)
|
2019-11-29 14:26:59 +09:00
|
|
|
}
|
2019-11-28 15:48:36 +09:00
|
|
|
});
|
|
|
|
|
2019-12-17 17:24:06 +09:00
|
|
|
const passwordChangeUrl = urlInfo.webLink.filter(
|
2020-01-03 11:05:17 +09:00
|
|
|
weblink => weblink.key === WebLinkType.ChgPassword
|
2019-12-17 17:24:06 +09:00
|
|
|
);
|
|
|
|
if (passwordChangeUrl.length > 0) {
|
2019-12-19 08:49:06 +09:00
|
|
|
const appUserInfo = this.localStorageService.encGet<AppUserInfo>(
|
|
|
|
KEY_APP_USER_INFO,
|
|
|
|
environment.customConfig.appKey
|
|
|
|
);
|
|
|
|
const loginPw = appUserInfo.loginPw;
|
|
|
|
const loginId = appUserInfo.loginId;
|
|
|
|
|
|
|
|
const url = passwordChangeUrl[0].url
|
|
|
|
.replace(/(\(%USER_ID%\))/g, loginId)
|
|
|
|
.replace(
|
|
|
|
/(\(%USER_PASS%\))/g,
|
|
|
|
this.daesangCipherService.encryptForWebLink(loginPw)
|
|
|
|
);
|
|
|
|
|
|
|
|
this.nativeService.openDefaultBrowser(url);
|
2019-11-28 15:48:36 +09:00
|
|
|
}
|
2019-12-17 17:24:06 +09:00
|
|
|
|
|
|
|
this.store.dispatch(logout());
|
|
|
|
|
|
|
|
// // [GROUP]
|
|
|
|
// const result = await this.dialogService.open<
|
|
|
|
// ChangePasswordDialogComponent,
|
|
|
|
// ChangePasswordDialogData,
|
|
|
|
// ChangePasswordDialogResult
|
|
|
|
// >(ChangePasswordDialogComponent, {
|
|
|
|
// width: '500px',
|
|
|
|
// height: '500px',
|
|
|
|
// disableClose: false,
|
|
|
|
// data: {
|
|
|
|
// loginId: loginInfo.loginId,
|
|
|
|
// encryptedLoginPw: loginInfo.loginPw,
|
|
|
|
// phoneNumber: loginRes.userInfo.hpNumber
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// if (!!result && result.choice) {
|
|
|
|
// this.store.dispatch(
|
|
|
|
// userPasswordSet({
|
|
|
|
// req: {
|
|
|
|
// companyCode: loginInfo.companyCode,
|
|
|
|
// loginId: loginInfo.loginId,
|
|
|
|
// oldLoginPw: result.currentLoginPw,
|
|
|
|
// newLoginPw: result.newLoginPw
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// this.store.dispatch(logout());
|
|
|
|
// return;
|
|
|
|
// }
|
2019-11-28 15:48:36 +09:00
|
|
|
}
|
2019-10-04 10:19:55 +09:00
|
|
|
})
|
|
|
|
),
|
|
|
|
{ dispatch: false }
|
|
|
|
);
|
|
|
|
|
|
|
|
privacyAgree$ = createEffect(() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(privacyAgree),
|
|
|
|
map(action => {
|
|
|
|
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
|
|
|
KEY_LOGIN_INFO
|
|
|
|
);
|
|
|
|
const environmentsInfo = this.sessionStorageService.get<
|
|
|
|
EnvironmentsInfo
|
|
|
|
>(KEY_ENVIRONMENTS_INFO);
|
|
|
|
|
|
|
|
return {
|
|
|
|
loginInfo,
|
|
|
|
environmentsInfo,
|
2019-11-14 14:19:59 +09:00
|
|
|
loginResponse: action.loginRes
|
2019-10-04 10:19:55 +09:00
|
|
|
};
|
|
|
|
}),
|
|
|
|
exhaustMap(params =>
|
|
|
|
this.piService
|
|
|
|
.userTermsAction({
|
|
|
|
userSeq: params.loginResponse.userSeq,
|
|
|
|
token: params.loginResponse.tokenString,
|
2019-11-14 14:19:59 +09:00
|
|
|
deviceType: params.environmentsInfo.deviceType
|
2019-10-04 10:19:55 +09:00
|
|
|
})
|
|
|
|
.pipe(
|
|
|
|
map((res: UserTermsActionResponse) => {
|
|
|
|
if ('00' !== res.responseCode) {
|
|
|
|
return privacyAgreeFailure({ error: 'Failed' });
|
|
|
|
} else {
|
|
|
|
return privacyAgreeSuccess();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
catchError(error => of(privacyAgreeFailure({ error })))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-11-29 14:26:59 +09:00
|
|
|
userPasswordSet$ = createEffect(() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(userPasswordSet),
|
|
|
|
map(action => action.req),
|
|
|
|
exhaustMap(req =>
|
|
|
|
this.serviceProtocolService.userPasswordSet(req).pipe(
|
|
|
|
map((res: UserPasswordSetResponse) => {
|
|
|
|
return userPasswordSetSuccess({
|
|
|
|
res
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
catchError(error => of(userPasswordSetFailure({ error })))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-11-29 15:09:47 +09:00
|
|
|
userPasswordSetSuccess$ = createEffect(
|
|
|
|
() => {
|
|
|
|
return this.actions$.pipe(
|
|
|
|
ofType(userPasswordSetSuccess),
|
2019-11-29 16:08:24 +09:00
|
|
|
tap(async action => {
|
|
|
|
await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
disableClose: true,
|
|
|
|
data: {
|
2020-01-08 12:30:39 +09:00
|
|
|
title: this.translateService.instant('accounts.changePassword'),
|
|
|
|
message: this.translateService.instant(
|
|
|
|
'accounts.results.changedPassword'
|
|
|
|
)
|
2019-11-29 16:08:24 +09:00
|
|
|
}
|
2019-11-29 15:09:47 +09:00
|
|
|
});
|
2019-11-29 16:08:24 +09:00
|
|
|
|
|
|
|
this.store.dispatch(logout());
|
2019-11-29 15:09:47 +09:00
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
{ dispatch: false }
|
|
|
|
);
|
|
|
|
|
|
|
|
userPasswordSetFailure$ = createEffect(
|
|
|
|
() => {
|
|
|
|
return this.actions$.pipe(
|
|
|
|
ofType(userPasswordSetFailure),
|
|
|
|
tap(action => {
|
|
|
|
this.snackBarService.open(
|
2020-01-08 12:30:39 +09:00
|
|
|
this.translateService.instant(
|
|
|
|
'accounts.errors.failToChangePassword'
|
|
|
|
),
|
2019-11-29 15:09:47 +09:00
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'bottom'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
},
|
|
|
|
{ dispatch: false }
|
|
|
|
);
|
|
|
|
|
2020-01-13 14:54:25 +09:00
|
|
|
infoUser$ = createEffect(() =>
|
|
|
|
this.actions$.pipe(
|
|
|
|
ofType(infoUser),
|
|
|
|
map(action => action.req),
|
|
|
|
exhaustMap(req =>
|
|
|
|
this.infoProtocolService.user(req).pipe(
|
|
|
|
map((res: UserResponse) => {
|
|
|
|
return infoUserSuccess({
|
|
|
|
res
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
catchError(error => of(infoUserFailure({ error })))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2019-09-18 15:02:21 +09:00
|
|
|
constructor(
|
|
|
|
private actions$: Actions,
|
2019-11-19 18:43:49 +09:00
|
|
|
private ngZone: NgZone,
|
2019-09-19 17:03:39 +09:00
|
|
|
private router: Router,
|
2019-10-04 10:19:55 +09:00
|
|
|
private store: Store<any>,
|
2019-12-19 08:49:06 +09:00
|
|
|
private localStorageService: LocalStorageService,
|
2019-10-04 10:19:55 +09:00
|
|
|
private sessionStorageService: SessionStorageService,
|
2019-09-18 15:02:21 +09:00
|
|
|
private piService: PiService,
|
2019-09-19 18:22:13 +09:00
|
|
|
private appAuthenticationService: AppAuthenticationService,
|
2020-03-20 13:57:50 +09:00
|
|
|
private externalApiService: ExternalApiService,
|
2019-11-28 13:19:19 +09:00
|
|
|
private protocolService: ProtocolService,
|
2019-11-19 18:43:49 +09:00
|
|
|
private authenticationProtocolService: AuthenticationProtocolService,
|
2020-01-13 14:54:25 +09:00
|
|
|
private infoProtocolService: InfoProtocolService,
|
2019-11-29 14:26:59 +09:00
|
|
|
private serviceProtocolService: ServiceProtocolService,
|
2020-01-08 12:30:39 +09:00
|
|
|
private translateService: TranslateService,
|
2019-09-19 17:03:39 +09:00
|
|
|
private dialogService: DialogService,
|
2019-11-29 15:09:47 +09:00
|
|
|
private snackBarService: SnackBarService,
|
2019-09-27 12:53:21 +09:00
|
|
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
2019-12-19 08:49:06 +09:00
|
|
|
private logger: NGXLogger,
|
|
|
|
private daesangCipherService: DaesangCipherService
|
2019-09-18 15:02:21 +09:00
|
|
|
) {}
|
|
|
|
}
|