totp ing
This commit is contained in:
parent
bd97afccc5
commit
590b543ac2
|
@ -16,7 +16,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>Key & Backup Code</p>
|
<p>Key & Backup Code</p>
|
||||||
|
<div>{{totpMap.key}}</div>
|
||||||
|
<form fxLayout="column" fxLayoutAlign="start stretch" [formGroup]="totpForm" (ngSubmit)="totpRegistClick()">
|
||||||
|
<input type="text"
|
||||||
|
id="code" class="input"
|
||||||
|
placeholder="Please enter your code"
|
||||||
|
formControlName="code" required matInput>
|
||||||
|
</form>
|
||||||
<!--QR Code print & Key Print-->
|
<!--QR Code print & Key Print-->
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-top-space-10" dir="rtl">
|
<div class="ui-top-space-10" dir="rtl">
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { AuthSelector } from 'packages/member/store';
|
||||||
import { TotpSelector } from 'packages/member/store';
|
import { TotpSelector } from 'packages/member/store';
|
||||||
import { Member } from 'packages/member/model/Member';
|
import { Member } from 'packages/member/model/Member';
|
||||||
import { MemberTotp } from 'packages/member/model/MemberTotp';
|
import { MemberTotp } from 'packages/member/model/MemberTotp';
|
||||||
|
import {RPCClientError} from '../../../../../../@loafer/ng-rpc/protocol';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-config-setting',
|
selector: 'of-config-setting',
|
||||||
|
@ -23,8 +24,11 @@ import { MemberTotp } from 'packages/member/model/MemberTotp';
|
||||||
})
|
})
|
||||||
export class ConfigSettingComponent implements OnInit, AfterContentInit {
|
export class ConfigSettingComponent implements OnInit, AfterContentInit {
|
||||||
member: Member;
|
member: Member;
|
||||||
|
totpState$ = this.store.pipe(select(TotpSelector.select('totp')));
|
||||||
|
totpMap: any;
|
||||||
|
totpForm: FormGroup;
|
||||||
|
|
||||||
@Input() selectedItem: any;
|
@Input() selectedItem: any;
|
||||||
@Input() totpVO: MemberTotp;
|
|
||||||
@Output() close = new EventEmitter();
|
@Output() close = new EventEmitter();
|
||||||
@Input() totpSettingDisplay;
|
@Input() totpSettingDisplay;
|
||||||
|
|
||||||
|
@ -35,11 +39,45 @@ export class ConfigSettingComponent implements OnInit, AfterContentInit {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.totpState$.subscribe(
|
||||||
|
(m: any) => {
|
||||||
|
if (m != null) {
|
||||||
|
this.totpMap = m;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(error: RPCClientError) => {
|
||||||
|
console.log(error.response.message);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterContentInit() {
|
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() {
|
onCancel() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<p-dialog header="{{headerItem}}" [modal]="true" [width]="1200" [(visible)]="totpSettingDisplay" [showHeader]="true" [closeOnEscape]="false">
|
<p-dialog header="{{headerItem}}" [modal]="true" [width]="1200" [(visible)]="totpSettingDisplay" [showHeader]="true" [closeOnEscape]="false">
|
||||||
<of-config-setting [selectedItem]="selectedItem" [totpVO]="totpVO" (close)="onTotpSettingClose()"></of-config-setting>
|
<of-config-setting [selectedItem]="selectedItem" (close)="onTotpSettingClose()"></of-config-setting>
|
||||||
</p-dialog>
|
</p-dialog>
|
||||||
|
|
||||||
<p-dataView [value]="lists" [paginator]="false" [rows]="5">
|
<p-dataView [value]="lists" [paginator]="false" [rows]="5">
|
||||||
|
|
|
@ -5,9 +5,7 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
|
||||||
import * as TotpStore from 'packages/member/store/totp';
|
import * as TotpStore from 'packages/member/store/totp';
|
||||||
import { AuthSelector } from 'packages/member/store';
|
import { AuthSelector } from 'packages/member/store';
|
||||||
import { TotpSelector } from 'packages/member/store';
|
|
||||||
import { Member } from 'packages/member/model/Member';
|
import { Member } from 'packages/member/model/Member';
|
||||||
import {MemberTotp} from '../../../model/MemberTotp';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-settings-totp',
|
selector: 'of-settings-totp',
|
||||||
|
@ -18,10 +16,8 @@ export class TotpComponent implements OnInit, AfterContentInit {
|
||||||
member: Member;
|
member: Member;
|
||||||
selectedItem: any;
|
selectedItem: any;
|
||||||
totpSettingDisplay = false;
|
totpSettingDisplay = false;
|
||||||
errorMessage: string | null;
|
|
||||||
totpForm: FormGroup;
|
totpForm: FormGroup;
|
||||||
headerItem: string;
|
headerItem: string;
|
||||||
totpVO: MemberTotp;
|
|
||||||
|
|
||||||
formErrors = {
|
formErrors = {
|
||||||
'code': '',
|
'code': '',
|
||||||
|
@ -59,27 +55,6 @@ export class TotpComponent implements OnInit, AfterContentInit {
|
||||||
console.log(error);
|
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) {
|
on2factorConfig(event: Event, item: any) {
|
||||||
|
@ -89,24 +64,10 @@ export class TotpComponent implements OnInit, AfterContentInit {
|
||||||
if (this.selectedItem.id === 3) {
|
if (this.selectedItem.id === 3) {
|
||||||
this.headerItem = '구글 인증기 설정하기';
|
this.headerItem = '구글 인증기 설정하기';
|
||||||
this.totpSettingDisplay = true;
|
this.totpSettingDisplay = true;
|
||||||
// dispatch
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onTotpSettingClose() {
|
onTotpSettingClose() {
|
||||||
this.totpSettingDisplay = false;
|
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);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ export class MemberTotpService {
|
||||||
public createTotp(member: Member): Observable<MemberTotp[]> {
|
public createTotp(member: Member): Observable<MemberTotp[]> {
|
||||||
// Todo Store get member object
|
// Todo Store get member object
|
||||||
|
|
||||||
return this.rpcService.call<MemberTotp[]>('MemberTotpService.createTotp', {Member: member});
|
return this.rpcService.call<MemberTotp[]>('MemberTotpService.createTotp', member);
|
||||||
}
|
}
|
||||||
|
|
||||||
public regist(member: Member, secretCode: string, code: string): Observable<boolean> {
|
public regist(member: Member, secretCode: string, code: string): Observable<boolean> {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export enum ActionType {
|
||||||
export class CreateTotp implements Action {
|
export class CreateTotp implements Action {
|
||||||
readonly type = ActionType.CreateTotp;
|
readonly type = ActionType.CreateTotp;
|
||||||
|
|
||||||
constructor(public payload: {member: Member}) {}
|
constructor(public payload: Member) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateTotpSuccess implements Action {
|
export class CreateTotpSuccess implements Action {
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class Effects {
|
||||||
.map((action: CreateTotp) => action.payload)
|
.map((action: CreateTotp) => action.payload)
|
||||||
.switchMap(payload => {
|
.switchMap(payload => {
|
||||||
// this._returnURL = payload.returnURL;
|
// this._returnURL = payload.returnURL;
|
||||||
return this.memberTotpService.createTotp(payload.member);
|
return this.memberTotpService.createTotp(payload);
|
||||||
})
|
})
|
||||||
.map((result: any) => {
|
.map((result: any) => {
|
||||||
const key = result['key'];
|
const key = result['key'];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user