From 590b543ac2b04de39a6bba0bbcfde96b580e20af Mon Sep 17 00:00:00 2001 From: geek Date: Thu, 19 Apr 2018 22:05:39 +0900 Subject: [PATCH] totp ing --- .../totp/config/config-setting.component.html | 8 +++- .../totp/config/config-setting.component.ts | 42 ++++++++++++++++++- .../settings/totp/totp.component.html | 2 +- .../component/settings/totp/totp.component.ts | 39 ----------------- .../member/service/member-totp.service.ts | 2 +- src/packages/member/store/totp/totp.action.ts | 2 +- src/packages/member/store/totp/totp.effect.ts | 2 +- 7 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/packages/member/component/settings/totp/config/config-setting.component.html b/src/packages/member/component/settings/totp/config/config-setting.component.html index 82ed1a8..ad21388 100644 --- a/src/packages/member/component/settings/totp/config/config-setting.component.html +++ b/src/packages/member/component/settings/totp/config/config-setting.component.html @@ -16,7 +16,13 @@

Key & Backup Code

- +
{{totpMap.key}}
+
+ +
diff --git a/src/packages/member/component/settings/totp/config/config-setting.component.ts b/src/packages/member/component/settings/totp/config/config-setting.component.ts index 4603f69..06e5d10 100644 --- a/src/packages/member/component/settings/totp/config/config-setting.component.ts +++ b/src/packages/member/component/settings/totp/config/config-setting.component.ts @@ -15,6 +15,7 @@ import { AuthSelector } from 'packages/member/store'; import { TotpSelector } from 'packages/member/store'; import { Member } from 'packages/member/model/Member'; import { MemberTotp } from 'packages/member/model/MemberTotp'; +import {RPCClientError} from '../../../../../../@loafer/ng-rpc/protocol'; @Component({ selector: 'of-config-setting', @@ -23,8 +24,11 @@ import { MemberTotp } from 'packages/member/model/MemberTotp'; }) export class ConfigSettingComponent implements OnInit, AfterContentInit { member: Member; + totpState$ = this.store.pipe(select(TotpSelector.select('totp'))); + totpMap: any; + totpForm: FormGroup; + @Input() selectedItem: any; - @Input() totpVO: MemberTotp; @Output() close = new EventEmitter(); @Input() totpSettingDisplay; @@ -35,11 +39,45 @@ export class ConfigSettingComponent implements OnInit, AfterContentInit { ) { } ngOnInit() { - + this.totpState$.subscribe( + (m: any) => { + if (m != null) { + this.totpMap = m; + } + }, + (error: RPCClientError) => { + console.log(error.response.message); + } + ); } ngAfterContentInit() { + this.store.select(AuthSelector.select('member')).subscribe( + (member: Member) => { + this.member = member; + this.store.dispatch(new TotpStore.CreateTotp(this.member)); + }, + (error) => { + console.log(error); + } + ); + + } + + + totpRegistClick() { + const code = this.totpForm.value['code']; + const secretCode = 'X6AWAK573M5372NM'; + + this.store.select(AuthSelector.select('member')).subscribe( + (member: Member) => { + this.store.dispatch(new TotpStore.Regist({ member, secretCode, code })); + }, + (error) => { + console.log(error); + } + ); } onCancel() { diff --git a/src/packages/member/component/settings/totp/totp.component.html b/src/packages/member/component/settings/totp/totp.component.html index 68c312d..b3acc9c 100644 --- a/src/packages/member/component/settings/totp/totp.component.html +++ b/src/packages/member/component/settings/totp/totp.component.html @@ -1,5 +1,5 @@ - + diff --git a/src/packages/member/component/settings/totp/totp.component.ts b/src/packages/member/component/settings/totp/totp.component.ts index b0e7d3e..3b5240a 100644 --- a/src/packages/member/component/settings/totp/totp.component.ts +++ b/src/packages/member/component/settings/totp/totp.component.ts @@ -5,9 +5,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import * as TotpStore from 'packages/member/store/totp'; import { AuthSelector } from 'packages/member/store'; -import { TotpSelector } from 'packages/member/store'; import { Member } from 'packages/member/model/Member'; -import {MemberTotp} from '../../../model/MemberTotp'; @Component({ selector: 'of-settings-totp', @@ -18,10 +16,8 @@ export class TotpComponent implements OnInit, AfterContentInit { member: Member; selectedItem: any; totpSettingDisplay = false; - errorMessage: string | null; totpForm: FormGroup; headerItem: string; - totpVO: MemberTotp; formErrors = { 'code': '', @@ -59,27 +55,6 @@ export class TotpComponent implements OnInit, AfterContentInit { console.log(error); } ); - - // this.listStore.select(AuthSelector.select('member')).subscribe( - // (member: Member) => { - // this.store.dispatch(new TotpRegistStore.createTotp(member)); - // }, - // (error) => { - // console.log(error); - // } - // ); - // - // this.probes$.subscribe( - // (probes: boo) => { - // console.log(probes); - // this.dataSource = new MatTableDataSource(probes); - // this.dataSource.sort = this.sort; - // }, - // (error: RPCError) => { - // console.log(error.response.message); - // } - // ); - } on2factorConfig(event: Event, item: any) { @@ -89,24 +64,10 @@ export class TotpComponent implements OnInit, AfterContentInit { if (this.selectedItem.id === 3) { this.headerItem = '구글 인증기 설정하기'; this.totpSettingDisplay = true; - // dispatch } } onTotpSettingClose() { this.totpSettingDisplay = false; } - registClick() { - const code = this.totpForm.value['code']; - const secretCode = 'X6AWAK573M5372NM'; - - this.store.select(AuthSelector.select('member')).subscribe( - (member: Member) => { - this.store.dispatch(new TotpStore.Regist({ member, secretCode, code })); - }, - (error) => { - console.log(error); - } - ); - } } diff --git a/src/packages/member/service/member-totp.service.ts b/src/packages/member/service/member-totp.service.ts index d1afbb0..7d444df 100644 --- a/src/packages/member/service/member-totp.service.ts +++ b/src/packages/member/service/member-totp.service.ts @@ -16,7 +16,7 @@ export class MemberTotpService { public createTotp(member: Member): Observable { // Todo Store get member object - return this.rpcService.call('MemberTotpService.createTotp', {Member: member}); + return this.rpcService.call('MemberTotpService.createTotp', member); } public regist(member: Member, secretCode: string, code: string): Observable { diff --git a/src/packages/member/store/totp/totp.action.ts b/src/packages/member/store/totp/totp.action.ts index b4a7407..5c0600c 100644 --- a/src/packages/member/store/totp/totp.action.ts +++ b/src/packages/member/store/totp/totp.action.ts @@ -21,7 +21,7 @@ export enum ActionType { export class CreateTotp implements Action { readonly type = ActionType.CreateTotp; - constructor(public payload: {member: Member}) {} + constructor(public payload: Member) {} } export class CreateTotpSuccess implements Action { diff --git a/src/packages/member/store/totp/totp.effect.ts b/src/packages/member/store/totp/totp.effect.ts index 97bb46d..7e3261c 100644 --- a/src/packages/member/store/totp/totp.effect.ts +++ b/src/packages/member/store/totp/totp.effect.ts @@ -49,7 +49,7 @@ export class Effects { .map((action: CreateTotp) => action.payload) .switchMap(payload => { // this._returnURL = payload.returnURL; - return this.memberTotpService.createTotp(payload.member); + return this.memberTotpService.createTotp(payload); }) .map((result: any) => { const key = result['key'];