From c1df332f1e8fbce0eabad6375c19f8a00fac7071 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Fri, 4 Oct 2019 10:19:55 +0900 Subject: [PATCH] postLogin is implemented --- .../src/app/app.module.ts | 2 + .../src/app/resolvers/messenger.resolver.ts | 35 ++-- .../store/account/authentication/actions.ts | 52 +++++- .../store/account/authentication/effects.ts | 159 +++++++++++++++++- .../store/account/authentication/reducers.ts | 2 +- .../app/store/account/authentication/state.ts | 8 +- .../src/app/store/account/index.ts | 16 +- .../src/app/store/account/privacy/actions.ts | 25 --- .../src/app/store/account/privacy/effects.ts | 157 ----------------- .../src/app/store/account/privacy/index.ts | 4 - .../src/app/store/account/privacy/reducers.ts | 4 - .../src/app/store/account/privacy/state.ts | 11 -- .../app/store/setting/version-info/actions.ts | 14 +- .../app/store/setting/version-info/effects.ts | 26 ++- .../store/setting/version-info/reducers.ts | 22 +-- .../src/public-api.ts | 4 + 16 files changed, 260 insertions(+), 281 deletions(-) delete mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/actions.ts delete mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/effects.ts delete mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/index.ts delete mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/reducers.ts delete mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/state.ts diff --git a/projects/ucap-webmessenger-app/src/app/app.module.ts b/projects/ucap-webmessenger-app/src/app/app.module.ts index 01018b73..b0f1936a 100644 --- a/projects/ucap-webmessenger-app/src/app/app.module.ts +++ b/projects/ucap-webmessenger-app/src/app/app.module.ts @@ -15,6 +15,7 @@ import { UCapProtocolModule } from '@ucap-webmessenger/protocol'; import { UCapAuthenticationProtocolModule } from '@ucap-webmessenger/protocol-authentication'; import { UCapInnerProtocolModule } from '@ucap-webmessenger/protocol-inner'; import { UCapOptionProtocolModule } from '@ucap-webmessenger/protocol-option'; +import { UCapServiceProtocolModule } from '@ucap-webmessenger/protocol-service'; import { UCapSyncProtocolModule } from '@ucap-webmessenger/protocol-sync'; import { UCapUiModule } from '@ucap-webmessenger/ui'; @@ -67,6 +68,7 @@ import { GUARDS } from './guards'; UCapAuthenticationProtocolModule.forRoot(), UCapInnerProtocolModule.forRoot(), UCapOptionProtocolModule.forRoot(), + UCapServiceProtocolModule.forRoot(), UCapSyncProtocolModule.forRoot(), UCapUiModule.forRoot(), diff --git a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts index 038c87e7..d0084151 100644 --- a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts +++ b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts @@ -4,15 +4,12 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; -import { Observable, throwError, of, EMPTY, forkJoin } from 'rxjs'; +import { Observable, throwError, forkJoin } from 'rxjs'; import { map, tap, - mergeMap, catchError, take, - exhaustMap, - concatMap, switchMap, withLatestFrom } from 'rxjs/operators'; @@ -21,10 +18,7 @@ import { Store, select } from '@ngrx/store'; import { ProtocolService } from '@ucap-webmessenger/protocol'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; -import { - PublicApiService, - VersionInfo2Response -} from '@ucap-webmessenger/api-public'; +import { PublicApiService } from '@ucap-webmessenger/api-public'; import { LoginInfo, @@ -40,8 +34,6 @@ import { } from '@ucap-webmessenger/protocol-authentication'; import * as AuthenticationStore from '@app/store/account/authentication'; -import { ConnResponse } from 'projects/ucap-webmessenger-protocol-inner/src/lib/models/conn'; -import { PiService } from '@ucap-webmessenger/pi'; import { NGXLogger } from 'ngx-logger'; import { QueryProtocolService } from '@ucap-webmessenger/protocol-query'; import { OptionProtocolService } from '@ucap-webmessenger/protocol-option'; @@ -58,7 +50,6 @@ export class AppMessengerResolver implements Resolve { private store: Store, private sessionStorageService: SessionStorageService, private publicApiService: PublicApiService, - private piService: PiService, private protocolService: ProtocolService, private queryProtocolService: QueryProtocolService, private optionProtocolService: OptionProtocolService, @@ -72,8 +63,6 @@ export class AppMessengerResolver implements Resolve { routerStateSnapshot: RouterStateSnapshot ): void | Observable | Promise { return new Promise((resolve, reject) => { - let versionInfo2Res: VersionInfo2Response; - let connRres: ConnResponse; let loginRes: LoginResponse; const loginInfo = this.sessionStorageService.get( @@ -92,13 +81,14 @@ export class AppMessengerResolver implements Resolve { }) .pipe( take(1), + tap(res => { + this.store.dispatch(VersionInfoStore.versionInfo2Success({ res })); + }), switchMap(res => { - versionInfo2Res = res; - return this.protocolService.connect(versionInfo2Res.serverIp); + return this.protocolService.connect(res.serverIp); }), switchMap(() => this.innerProtocolService.conn({})), switchMap(res => { - connRres = res; return this.authenticationProtocolService.login({ loginId: loginInfo.loginId, loginPw: loginInfo.loginPw, @@ -119,19 +109,22 @@ export class AppMessengerResolver implements Resolve { productName: 'EZMessenger' }); }), - switchMap(res => - forkJoin([ + switchMap(res => { + loginRes = res; + return forkJoin([ this.queryProtocolService.auth({ deviceType: environmentsInfo.deviceType }), this.optionProtocolService.regView({}) - ]) - ), + ]); + }), map(([authRes, regViewRes]) => { this.store.dispatch( OptionStore.regViewSuccess({ res: regViewRes }) ); this.store.dispatch(QueryStore.authSuccess({ res: authRes })); + + this.store.dispatch(AuthenticationStore.postLogin({ loginRes })); }), withLatestFrom( this.store.pipe( @@ -162,7 +155,7 @@ export class AppMessengerResolver implements Resolve { () => { this.store.dispatch( AuthenticationStore.loginSuccess({ - loginInfo: loginRes + loginRes }) ); resolve(); diff --git a/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts b/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts index 1e10669f..c87419be 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/authentication/actions.ts @@ -3,7 +3,11 @@ import { createAction, props } from '@ngrx/store'; import { Login2Response } from '@ucap-webmessenger/pi'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; -import { LoginInfo } from '../../../types'; +import { LoginInfo } from '@app/types'; +import { + UserPasswordSetRequest, + UserPasswordSetResponse +} from '@ucap-webmessenger/protocol-service'; export const webLogin = createAction( '[Account::Authentication] Web Login', @@ -30,7 +34,7 @@ export const webLoginFailure = createAction( export const loginSuccess = createAction( '[Account::Authentication] Login Success', props<{ - loginInfo: LoginResponse; + loginRes: LoginResponse; }>() ); @@ -52,3 +56,47 @@ export const logoutConfirmation = createAction( export const logoutConfirmationDismiss = createAction( '[Account::Authentication] Logout Confirmation Dismiss' ); + +export const postLogin = createAction( + '[Account::Authentication] Post Login', + props<{ + loginRes: LoginResponse; + }>() +); + +export const privacyAgree = createAction( + '[Account::Authentication] Privacy Agree', + props<{ + loginRes: LoginResponse; + }>() +); + +export const privacyAgreeSuccess = createAction( + '[Account::Authentication] Privacy Agree Success' +); + +export const privacyAgreeFailure = createAction( + '[Account::Authentication] Privacy Agree Failure', + props<{ error: any }>() +); + +export const privacyDisagree = createAction( + '[Account::Authentication] Privacy Disagree' +); + +export const changePassword = createAction( + '[Account::Authentication] Change Password', + props<{ req: UserPasswordSetRequest }>() +); + +export const changePasswordSuccess = createAction( + '[Account::Authentication] Change Password Success', + props<{ + res: UserPasswordSetResponse; + }>() +); + +export const changePasswordFailure = createAction( + '[Account::Authentication] Change Password Failure', + props<{ error: any }>() +); 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 a6095306..c0253fd8 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 @@ -6,7 +6,11 @@ import { catchError, exhaustMap, map, tap, switchMap } from 'rxjs/operators'; import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { PiService, Login2Response } from '@ucap-webmessenger/pi'; +import { + PiService, + Login2Response, + UserTermsActionResponse +} from '@ucap-webmessenger/pi'; import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native'; import { DialogService, @@ -22,11 +26,30 @@ import { logoutConfirmationDismiss, webLogin, webLoginSuccess, - webLoginFailure + webLoginFailure, + postLogin, + privacyAgree, + privacyDisagree, + privacyAgreeFailure, + privacyAgreeSuccess, + changePassword, + changePasswordFailure, + changePasswordSuccess } from './actions'; -import { LoginInfo } from '../../../types'; -import { AppAuthenticationService } from '../../../services/authentication.service'; +import { + LoginInfo, + KEY_LOGIN_INFO, + EnvironmentsInfo, + KEY_ENVIRONMENTS_INFO +} from '@app/types'; +import { AppAuthenticationService } from '@app/services/authentication.service'; import { NGXLogger } from 'ngx-logger'; +import { Store } from '@ngrx/store'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { + ServiceProtocolService, + UserPasswordSetResponse +} from '@ucap-webmessenger/protocol-service'; @Injectable() export class Effects { @@ -125,11 +148,139 @@ export class Effects { ) ); + postLogin$ = createEffect( + () => + this.actions$.pipe( + ofType(postLogin), + map(action => action.loginRes), + tap(async loginRes => { + const loginInfo = this.sessionStorageService.get( + KEY_LOGIN_INFO + ); + const environmentsInfo = this.sessionStorageService.get< + EnvironmentsInfo + >(KEY_ENVIRONMENTS_INFO); + + if (!loginRes.privateInformationAgree) { + const privacyTotalUrl = this.piService.privacyTotalUrl({ + companyCode: loginInfo.companyCode, + userSeq: loginRes.userSeq, + token: loginRes.tokenString, + deviceType: environmentsInfo.deviceType, + localeCode: loginInfo.localeCode, + textOnly: 'true' + }); + + const result = await this.dialogService.open< + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult + >(ConfirmDialogComponent, { + width: '100%', + height: '500px', + disableClose: true, + data: { + title: '개인정보 동의' + // html: `