From 4da93a5351495f0ca82ba7ea6033a9dbad02e5dc Mon Sep 17 00:00:00 2001 From: Richard Park Date: Fri, 29 Nov 2019 16:08:24 +0900 Subject: [PATCH] bug fixed --- .../components/login.page.component.ts | 4 +- .../src/app/resolvers/messenger.resolver.ts | 55 ++++++++++++------- .../store/account/authentication/effects.ts | 23 ++++++-- .../src/lib/services/protocol.service.ts | 17 +++--- .../src/lib/types/error-code.ts | 48 ++++++++++++++++ .../src/lib/types/service.ts | 25 --------- .../src/public-api.ts | 1 + 7 files changed, 113 insertions(+), 60 deletions(-) create mode 100644 projects/ucap-webmessenger-protocol/src/lib/types/error-code.ts diff --git a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts index bad075ab..7734c421 100644 --- a/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts +++ b/projects/ucap-webmessenger-app/src/app/pages/account/components/login.page.component.ts @@ -69,7 +69,7 @@ export class LoginPageComponent implements OnInit, OnDestroy { >(AlertDialogComponent, { width: '360px', data: { - title: 'Alert', + title: '로그인', html: `아이디 또는 패스워드가
일치하지 않습니다.` } }); @@ -83,7 +83,7 @@ export class LoginPageComponent implements OnInit, OnDestroy { >(AlertDialogComponent, { width: '360px', data: { - title: 'Alert', + title: '로그인', html: `비밀번호 오류 횟수 초과입니다.
비밀번호를 확인하신 후
잠시 후 다시 시작해 주세요.` } }); 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 932580bf..4f07bfc3 100644 --- a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts +++ b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts @@ -16,7 +16,7 @@ import { import { Store, select } from '@ngrx/store'; -import { ProtocolService } from '@ucap-webmessenger/protocol'; +import { ProtocolService, ServerErrorCode } from '@ucap-webmessenger/protocol'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { PublicApiService, @@ -51,6 +51,7 @@ import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { environment } from '../../environments/environment'; +import { SnackBarService } from '@ucap-webmessenger/ui'; @Injectable() export class AppMessengerResolver implements Resolve { @@ -63,6 +64,7 @@ export class AppMessengerResolver implements Resolve { private optionProtocolService: OptionProtocolService, private authenticationProtocolService: AuthenticationProtocolService, private innerProtocolService: InnerProtocolService, + private snackBarService: SnackBarService, private logger: NGXLogger ) {} @@ -101,25 +103,38 @@ export class AppMessengerResolver implements Resolve { }), switchMap(() => this.innerProtocolService.conn({})), switchMap(res => { - return this.authenticationProtocolService.login({ - loginId: loginInfo.loginId, - loginPw: loginInfo.loginPw, - deviceType: environmentsInfo.deviceType, - deviceId: ' ', - token: '', - localeCode: loginInfo.localeCode, - pushId: ' ', - companyCode: loginInfo.companyCode, - passwordEncodingType: 1, - clientVersion: '', - reconnect: false, - ip: 'localhost', - hostName: '', - ssoMode: SSOMode.AUTH, - userSpecificInformation: 'PRO_000482', - productId: environment.productConfig.productId, - productName: environment.productConfig.productName - }); + return this.authenticationProtocolService + .login({ + loginId: loginInfo.loginId, + loginPw: loginInfo.loginPw, + deviceType: environmentsInfo.deviceType, + deviceId: ' ', + token: '', + localeCode: loginInfo.localeCode, + pushId: ' ', + companyCode: loginInfo.companyCode, + passwordEncodingType: 1, + clientVersion: '', + reconnect: false, + ip: 'localhost', + hostName: '', + ssoMode: SSOMode.AUTH, + userSpecificInformation: 'PRO_000482', + productId: environment.productConfig.productId, + productName: environment.productConfig.productName + }) + .pipe( + catchError(err => { + switch (err as ServerErrorCode) { + case ServerErrorCode.ERRCD_IDPW: + break; + + default: + break; + } + return throwError(err); + }) + ); }), switchMap(res => { loginRes = res; 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 eae6c147..aff0ba2b 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 @@ -17,7 +17,10 @@ import { ConfirmDialogComponent, ConfirmDialogData, ConfirmDialogResult, - SnackBarService + SnackBarService, + AlertDialogComponent, + AlertDialogData, + AlertDialogResult } from '@ucap-webmessenger/ui'; import { @@ -367,11 +370,21 @@ export class Effects { () => { return this.actions$.pipe( ofType(userPasswordSetSuccess), - tap(action => { - this.snackBarService.open(`비밀번호 변경이 완료 되었습니다`, '', { - duration: 3000, - verticalPosition: 'bottom' + tap(async action => { + await this.dialogService.open< + AlertDialogComponent, + AlertDialogData, + AlertDialogResult + >(AlertDialogComponent, { + width: '360px', + disableClose: true, + data: { + title: '비밀번호 변경', + message: '비밀번호가 변경되었습니다. 다시 로그인하여 주십시오' + } }); + + this.store.dispatch(logout()); }) ); }, diff --git a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts index 3341ff6d..f1abf007 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/services/protocol.service.ts @@ -10,16 +10,17 @@ import { NGXLogger } from 'ngx-logger'; import { makeWebSocketObservable, GetWebSocketResponses, - NormalClosureMessage, + NormalClosureMessage } from '@ucap-webmessenger/web-socket'; import { PacketBody } from '../protocols/packet'; import { PacketBodyValueDivider, - PacketBodyDivider, + PacketBodyDivider } from '../types/packet-body-divider'; import { PacketBodyValue } from '../types/packet-body-value.type'; -import { SSVC_TYPE_ERROR_RES, ServerErrorCode } from '../types/service'; +import { SSVC_TYPE_ERROR_RES } from '../types/service'; +import { ServerErrorCode } from '../types/error-code'; import { ProtocolMessage } from '../protocols/protocol'; import { _MODULE_CONFIG } from '../config/token'; @@ -37,7 +38,7 @@ interface RequestState { } @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class ProtocolService { readonly urls: Urls; @@ -186,7 +187,7 @@ export class ProtocolService { packet = this.encodePacket(serviceType, subServiceType, [ ...bodyList, - { type: PacketBodyValue.RequestId, value: requestId }, + { type: PacketBodyValue.RequestId, value: requestId } ]); responseSubject = new Subject().pipe( @@ -209,7 +210,7 @@ export class ProtocolService { this.pendingRequests.set(requestId, { subject: responseSubject, - request: { serviceType, subServiceType, bodyList }, + request: { serviceType, subServiceType, bodyList } }); } else { packet = this.encodePacket(serviceType, subServiceType, bodyList); @@ -302,8 +303,8 @@ export class ProtocolService { serviceType, subServiceType, senderSeq, - bodyList, - }, + bodyList + } }; } diff --git a/projects/ucap-webmessenger-protocol/src/lib/types/error-code.ts b/projects/ucap-webmessenger-protocol/src/lib/types/error-code.ts new file mode 100644 index 00000000..d990eb67 --- /dev/null +++ b/projects/ucap-webmessenger-protocol/src/lib/types/error-code.ts @@ -0,0 +1,48 @@ +export enum ServerErrorCode { + /** 서버측에서 연결을 종료했습니다 */ + ERRCD_FORCE_CLOSE = 10, + /** 통신 프로토콜이 일치하지않습니다 (최신 프로그램으로 업데이트 해주세요) */ + ERRCD_PROTOCOL = 11, + /** 클라이언트 버전이 일치하지않습니다 (최신 프로그램으로 업데이트 해주세요) */ + ERRCD_VERSION = 12, + /** 인증되지않은 기기입니다 */ + ERRCD_DID = 13, + /** 로그인 아이디 또는 패스워드가 일치하지않습니다 */ + ERRCD_IDPW = 14, + /** 다른 디바이스에서 로그인했습니다 */ + ERRCD_DUPLICATE = 15, + /** 인증 토큰이 만료되었습니다 */ + ERRCD_TOKEN = 16, + /** 프로그램을 재설치 바랍니다 */ + ERRCD_SETUP_MAIN = 17, + /** 권한자/관리자에 의해 종료되었습니다 */ + ERRCD_FORCE_INIT = 18, + /** 사용권한이 없습니다 */ + ERRCD_NEED_AUTH_CLIENT = 19, + /** DEMO 서비스 기간이 종료되었습니다 */ + ERRCD_SVC_EXPIRE = 99, + /** 요청 처리를 실패했습니다 */ + ERRCD_FAILED = 100, + /** 데이터 처리를 실패했습니다 */ + ERRCD_DATABASE = 101, + /** 최대치 넘음 */ + ERRCD_EXCESS = 102, + /** 인증이 필요한 요청입니다 */ + ERRCD_NEED_AUTH = 103, + /** */ + ERRCD_USERINFO = 104, + /** 요청 처리를 실패했습니다(에러코드) */ + ERRCD_INVALID_PARAM = 105, + /** 대화방에 함께 참여할 수 없는 사용자가 있습니다 */ + ERRCD_INVALID_INVITE_USER = 106, + /** 상대방이 온라인 상태가 아닙니다 */ + ERRCD_NOT_ONLINE = 200, + /** 패스워드 유효 기간이 만료 되었습니다 */ + ERRCD_PW_EXPIRED = 300, + /** 요청을 처리할 권한이 없습니다 */ + ERRCD_AUTH_DENY = 1000, + /** 암호화 처리 오류 */ + ERRCD_ENCRYPT = 1001, + /** 다른 IP로 접속 요청 */ + ERRCD_RECON = 1002 +} diff --git a/projects/ucap-webmessenger-protocol/src/lib/types/service.ts b/projects/ucap-webmessenger-protocol/src/lib/types/service.ts index 64296725..c9af8e49 100644 --- a/projects/ucap-webmessenger-protocol/src/lib/types/service.ts +++ b/projects/ucap-webmessenger-protocol/src/lib/types/service.ts @@ -1,26 +1 @@ export const SSVC_TYPE_ERROR_RES = 1000; - -export enum ServerErrorCode { - ERRCD_FORCE_CLOSE = 10, - ERRCD_PROTOCOL = 11, - ERRCD_VERSION = 12, - ERRCD_DID = 13, - ERRCD_IDPW = 14, - ERRCD_DUPLICATE = 15, - ERRCD_TOKEN = 16, - ERRCD_SETUP_MAIN = 17, - ERRCD_FORCE_INIT = 18, - ERRCD_SSO_AUTH = 19, - ERRCD_SSO_VALI = 20, - ERRCD_DEV_NOT_SUPPORTED = 21, - ERRCD_NO_MOBILE_PID = 22, - ERRCD_SVC_EXPIRE = 99, - ERRCD_FAILED = 100, - ERRCD_DATABASE = 101, - ERRCD_EXCESS = 102, - ERRCD_NEED_AUTH = 103, - ERRCD_USERINFO = 104, // ucap 은 없음. - ERRCD_AUTH_DENY = 1000, - ERRCD_ENCRYPT = 1001, // 패킷 암호화 오류 - ERRCD_RECON = 1002 // 다른 IP로 접속 요청 -} diff --git a/projects/ucap-webmessenger-protocol/src/public-api.ts b/projects/ucap-webmessenger-protocol/src/public-api.ts index 0f7b82be..2fa0d32f 100644 --- a/projects/ucap-webmessenger-protocol/src/public-api.ts +++ b/projects/ucap-webmessenger-protocol/src/public-api.ts @@ -10,6 +10,7 @@ export * from './lib/services/protocol.service'; export * from './lib/types/packet-body-divider'; export * from './lib/types/packet-body-value.type'; export * from './lib/types/service'; +export * from './lib/types/error-code'; export * from './lib/ucap-protocol.module';