From c49e7e59311b3c9589d4155cf31227f7761e893a Mon Sep 17 00:00:00 2001 From: Richard Park Date: Tue, 24 Sep 2019 14:53:22 +0900 Subject: [PATCH] agree of privacy is modified --- .../src/lib/utils/url.util.ts | 16 ++ .../ucap-webmessenger-api/src/public-api.ts | 1 + .../src/app/resolvers/messenger.resolver.ts | 2 +- .../app/services/authentication.service.ts | 4 +- .../store/account/authentication/effects.ts | 2 +- .../src/app/store/account/index.ts | 16 +- .../src/app/store/account/privacy/actions.ts | 25 +++ .../src/app/store/account/privacy/effects.ts | 145 ++++++++++++++++++ .../src/app/store/account/privacy/index.ts | 4 + .../src/app/store/account/privacy/reducers.ts | 4 + .../src/app/store/account/privacy/state.ts | 11 ++ .../src/app/store/setting/index.ts | 9 ++ .../src/app/store/setting/init/actions.ts | 3 + .../src/app/store/setting/init/effects.ts | 6 + .../src/app/store/setting/init/index.ts | 4 + .../src/app/store/setting/init/reducers.ts | 4 + .../src/app/store/setting/init/state.ts | 10 ++ .../src/app/types/login-info.type.ts | 4 +- .../src/environments/environment.type.ts | 6 + .../src/lib/models/login2.ts | 1 + .../ucap-webmessenger-pi/src/lib/models/pi.ts | 1 - .../src/lib/models/privacy-total.ts | 27 ++++ .../src/lib/models/user-terms-action.ts | 37 +++++ .../src/lib/services/pi.service.ts | 41 ++++- .../src/lib/types/module-config.ts | 27 +++- .../ucap-webmessenger-pi/src/public-api.ts | 2 + .../lib/dialogs/confirm.dialog.component.html | 6 +- .../lib/dialogs/confirm.dialog.component.ts | 18 ++- .../src/lib/ucap-ui.module.ts | 10 +- 29 files changed, 426 insertions(+), 20 deletions(-) create mode 100644 projects/ucap-webmessenger-api/src/lib/utils/url.util.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/actions.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/effects.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/index.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/reducers.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/account/privacy/state.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/setting/init/actions.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/setting/init/effects.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/setting/init/index.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/setting/init/reducers.ts create mode 100644 projects/ucap-webmessenger-app/src/app/store/setting/init/state.ts create mode 100644 projects/ucap-webmessenger-pi/src/lib/models/privacy-total.ts create mode 100644 projects/ucap-webmessenger-pi/src/lib/models/user-terms-action.ts diff --git a/projects/ucap-webmessenger-api/src/lib/utils/url.util.ts b/projects/ucap-webmessenger-api/src/lib/utils/url.util.ts new file mode 100644 index 00000000..c4126df3 --- /dev/null +++ b/projects/ucap-webmessenger-api/src/lib/utils/url.util.ts @@ -0,0 +1,16 @@ +import { Parameter } from './parameter.util'; +import { HttpParams } from '@angular/common/http'; + +export class UrlUtil { + public static format(href: string, param: Parameter): string { + const params = new HttpParams({ fromObject: param }).toString(); + + if (params.length === 0) { + return href; + } else { + const qIdx = href.indexOf('?'); + const sep: string = qIdx === -1 ? '?' : qIdx < href.length - 1 ? '&' : ''; + return href + sep + params; + } + } +} diff --git a/projects/ucap-webmessenger-api/src/public-api.ts b/projects/ucap-webmessenger-api/src/public-api.ts index dd0d94ce..7c3bbaf2 100644 --- a/projects/ucap-webmessenger-api/src/public-api.ts +++ b/projects/ucap-webmessenger-api/src/public-api.ts @@ -7,3 +7,4 @@ export * from './lib/models/api'; export * from './lib/types/status-code.type'; export * from './lib/utils/parameter.util'; +export * from './lib/utils/url.util'; 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 f3b5cd4c..8ad76917 100644 --- a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts +++ b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts @@ -68,7 +68,7 @@ export class AppMessengerResolver implements Resolve { deviceType: loginInfo.deviceType, deviceId: ' ', token: '', - localeCode: LocaleCode.Korean, + localeCode: loginInfo.localeCode, pushId: ' ', companyCode: loginInfo.companyCode, passwordEncodingType: 1, diff --git a/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts b/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts index ea00f7f7..5e22890c 100644 --- a/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts @@ -7,7 +7,7 @@ import { LocalStorageService } from '@ucap-webmessenger/web-storage'; import { EnviromentUtilService } from '@ucap-webmessenger/util'; -import { DeviceType } from '@ucap-webmessenger/core'; +import { DeviceType, LocaleCode } from '@ucap-webmessenger/core'; import { LoginInfo, KEY_LOGIN_INFO } from '../types'; @Injectable({ @@ -30,6 +30,8 @@ export class AppAuthenticationService { login(loginInfo: LoginInfo, rememberMe: boolean) { let deviceType: DeviceType; + loginInfo = { ...loginInfo, localeCode: LocaleCode.Korean }; + if (this.enviromentUtilService.nodeWebkit()) { deviceType = DeviceType.PC; } else if (this.enviromentUtilService.android()) { 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 818aa464..33c3bcb1 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 @@ -48,7 +48,7 @@ export class Effects { }) .pipe( map((res: Login2Response) => { - if (res.status === ResponseStatus.Fail) { + if ('success' !== res.status.toLowerCase()) { return webLoginFailure({ error: 'Failed' }); } else { return webLoginSuccess({ diff --git a/projects/ucap-webmessenger-app/src/app/store/account/index.ts b/projects/ucap-webmessenger-app/src/app/store/account/index.ts index 13adc103..bc8bc382 100644 --- a/projects/ucap-webmessenger-app/src/app/store/account/index.ts +++ b/projects/ucap-webmessenger-app/src/app/store/account/index.ts @@ -2,16 +2,22 @@ import { Type } from '@angular/core'; import { Action, combineReducers, Selector, createSelector } from '@ngrx/store'; import * as AuthenticationStore from './authentication'; +import * as PrivacyStore from './privacy'; export interface State { authentication: AuthenticationStore.State; + privacy: PrivacyStore.State; } -export const effects: Type[] = [AuthenticationStore.Effects]; +export const effects: Type[] = [ + AuthenticationStore.Effects, + PrivacyStore.Effects +]; export function reducers(state: State | undefined, action: Action) { return combineReducers({ - authentication: AuthenticationStore.reducer + authentication: AuthenticationStore.reducer, + privacy: PrivacyStore.reducer })(state, action); } @@ -22,6 +28,12 @@ export function selectors(selector: Selector) { selector, (state: State) => state.authentication ) + ), + PrivacySelector: PrivacyStore.selectors( + createSelector( + selector, + (state: State) => state.privacy + ) ) }; } diff --git a/projects/ucap-webmessenger-app/src/app/store/account/privacy/actions.ts b/projects/ucap-webmessenger-app/src/app/store/account/privacy/actions.ts new file mode 100644 index 00000000..b31794d6 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/store/account/privacy/actions.ts @@ -0,0 +1,25 @@ +import { createAction, props } from '@ngrx/store'; + +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; + +export const agreeConfirmationNotNeeded = createAction( + '[Account::Privacy] Agree Confirmation not needed' +); + +export const agreeConfirmationYes = createAction( + '[Account::Privacy] Agree Confirmation Yes', + props<{ + loginInfo: LoginResponse; + }>() +); + +export const agreeConfirmationNo = createAction( + '[Account::Privacy] Agree Confirmation No' +); + +export const agreeSuccess = createAction('[Account::Privacy] Agree Success'); + +export const agreeFailure = createAction( + '[Account::Privacy] Agree Failure', + props<{ error: any }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/account/privacy/effects.ts b/projects/ucap-webmessenger-app/src/app/store/account/privacy/effects.ts new file mode 100644 index 00000000..32202e89 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/store/account/privacy/effects.ts @@ -0,0 +1,145 @@ +import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + +import { Actions, ofType, createEffect } from '@ngrx/effects'; + +import { of } from 'rxjs'; +import { catchError, exhaustMap, map } from 'rxjs/operators'; + +import { + PiService, + UserTermsActionResponse, + ResponseStatus +} from '@ucap-webmessenger/pi'; +import { + DialogService, + ConfirmDialogComponent, + ConfirmDialogData, + ConfirmDialogResult +} from '@ucap-webmessenger/ui'; + +import { AppAuthenticationService } from '@app/services/authentication.service'; +import { loginSuccess, logout } from '../authentication'; +import { + agreeConfirmationYes, + agreeConfirmationNo, + agreeConfirmationNotNeeded, + agreeSuccess, + agreeFailure +} from './actions'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; + +import { initSettings } from '@app/store/setting/init'; + +@Injectable() +export class Effects { + agreeConfirmation$ = createEffect(() => + this.actions$.pipe( + ofType(loginSuccess), + exhaustMap(async params => { + if (params.loginInfo.privateInformationAgree) { + return null; + } + const loginInfo = this.sessionStorageService.get( + KEY_LOGIN_INFO + ); + + const privacyTotalUrl = this.piService.privacyTotalUrl({ + companyCode: params.loginInfo.companyCode, + userSeq: params.loginInfo.userSeq, + token: params.loginInfo.tokenString, + deviceType: loginInfo.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: `