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: `