diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.html new file mode 100644 index 00000000..ab2a14fe --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.html @@ -0,0 +1 @@ + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.scss b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.spec.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.spec.ts new file mode 100644 index 00000000..518a4e50 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.spec.ts @@ -0,0 +1,27 @@ +/* tslint:disable:no-unused-variable */ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; +import { DebugElement } from '@angular/core'; + +import { ChangePasswordDialogComponent } from './change-password.dialog.component'; + +describe('ChangePasswordDialogComponent', () => { + let component: ChangePasswordDialogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ChangePasswordDialogComponent] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ChangePasswordDialogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.ts new file mode 100644 index 00000000..7cf9d439 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/change-password.dialog.component.ts @@ -0,0 +1,56 @@ +import { Component, OnInit, Inject, OnDestroy } from '@angular/core'; +import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; +import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; +import { KEY_VER_INFO } from '@app/types/ver-info.type'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; + +import { Store } from '@ngrx/store'; + +import { UserInfo } from '@ucap-webmessenger/protocol-sync'; +import { + UserInfoSS, + UserInfoF, + UserInfoDN +} from '@ucap-webmessenger/protocol-query'; +import { DialogService } from '@ucap-webmessenger/ui'; +import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; + +export interface ChangePasswordDialogData {} + +export interface ChangePasswordDialogResult { + choice: boolean; +} + +@Component({ + selector: 'app-change-password.dialog', + templateUrl: './change-password.dialog.component.html', + styleUrls: ['./change-password.dialog.component.scss'] +}) +export class ChangePasswordDialogComponent implements OnInit, OnDestroy { + loginRes: LoginResponse; + sessionVerinfo: VersionInfo2Response; + isMe: boolean; + + constructor( + public dialogRef: MatDialogRef< + ChangePasswordDialogData, + ChangePasswordDialogResult + >, + @Inject(MAT_DIALOG_DATA) public data: ChangePasswordDialogData, + private dialogService: DialogService, + private sessionStorageService: SessionStorageService, + private store: Store + ) { + this.sessionVerinfo = this.sessionStorageService.get( + KEY_VER_INFO + ); + this.loginRes = this.sessionStorageService.get( + KEY_LOGIN_RES_INFO + ); + } + + ngOnInit() {} + + ngOnDestroy(): void {} +} diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/index.ts new file mode 100644 index 00000000..c56cad1c --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/account/index.ts @@ -0,0 +1,3 @@ +import { ChangePasswordDialogComponent } from './change-password.dialog.component'; + +export const DIALOGS = [ChangePasswordDialogComponent]; diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts index 084b8128..f4ae8d86 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/index.ts @@ -1,3 +1,4 @@ +import { DIALOGS as ACCOUNT_DIALOGS } from './account'; import { DIALOGS as CHAT_DIALOGS } from './chat'; import { DIALOGS as GROUP_DIALOGS } from './group'; import { DIALOGS as MESSAGE_DIALOGS } from './message'; @@ -5,6 +6,7 @@ import { DIALOGS as PROFILE_DIALOGS } from './profile'; import { DIALOGS as SETTINGS_DIALOGS } from './settings'; export const DIALOGS = [ + ...ACCOUNT_DIALOGS, ...CHAT_DIALOGS, ...GROUP_DIALOGS, ...MESSAGE_DIALOGS, diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts index 2c5422fc..42b55016 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/messenger.layout.module.ts @@ -39,6 +39,7 @@ import { OverlayModule } from '@angular/cdk/overlay'; import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar'; import { UCapUiModule } from '@ucap-webmessenger/ui'; +import { UCapUiAccountModule } from '@ucap-webmessenger/ui-account'; import { UCapUiChatModule } from '@ucap-webmessenger/ui-chat'; import { UCapUiRoomModule } from '@ucap-webmessenger/ui-room'; import { UCapUiProfileModule } from '@ucap-webmessenger/ui-profile'; @@ -87,6 +88,7 @@ import { DIALOGS } from './dialogs'; PerfectScrollbarModule, UCapUiModule, + UCapUiAccountModule, UCapUiChatModule, UCapUiRoomModule, UCapUiProfileModule, 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 53304f6e..346ef739 100644 --- a/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/authentication.service.ts @@ -32,6 +32,7 @@ export class AppAuthenticationService { this.sessionStorageService.set(KEY_LOGIN_INFO, { ...loginInfo, + initPw: loginInfo.loginId === loginInfo.loginPw, loginPw: CryptoJS.enc.Hex.stringify(CryptoJS.SHA256(loginInfo.loginPw)) }); 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 7bf496f7..5636e48f 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 @@ -61,6 +61,11 @@ import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; import { ProtocolService } from '@ucap-webmessenger/protocol'; import { environment } from '../../../../environments/environment'; +import { + ChangePasswordDialogComponent, + ChangePasswordDialogData, + ChangePasswordDialogResult +} from '@app/layouts/messenger/dialogs/account/change-password.dialog.component'; @Injectable() export class Effects { @@ -133,10 +138,9 @@ export class Effects { tap(authed => { // this.ngZone.run(() => { // location.href = this.router.parseUrl('/account/login').toString(); + this.router.navigate(['/account/login']); this.appAuthenticationService.logout(); this.store.dispatch(logoutInitialize()); - - this.router.navigate(['/account/login']); // }); }) ), @@ -239,7 +243,13 @@ export class Effects { } } - if (!!loginRes.passwordExpired) { + if (loginInfo.initPw) { + this.store.dispatch(logout()); + + const passwordInitStep1Url = this.piService.passwordInitStep1Url({ + localeCode: loginInfo.localeCode + }); + const result = await this.dialogService.open< ConfirmDialogComponent, ConfirmDialogData, @@ -249,8 +259,8 @@ export class Effects { height: '500px', disableClose: true, data: { - title: '패스워드 만료', - message: '' + title: '패스워드 초기화', + html: `