ing
This commit is contained in:
parent
2802c1ae17
commit
41597d406d
|
@ -1,14 +1,16 @@
|
|||
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
||||
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||
import { Member } from '@overflow/commons-typescript/model/member';
|
||||
|
||||
@Component({
|
||||
selector: 'of-member-totp',
|
||||
templateUrl: './member-totp.component.html',
|
||||
})
|
||||
export class MemberTotpComponent implements OnInit {
|
||||
@Input() member;
|
||||
@Input() domainMember: DomainMember;
|
||||
@Input() totp;
|
||||
@Output() totpRegist = new EventEmitter<{code: string, secretCode: string}>();
|
||||
@Output() totpCreate = new EventEmitter();
|
||||
@Output() regist = new EventEmitter<{member: Member, code: string, secretCode: string}>();
|
||||
@Output() create = new EventEmitter<Member>();
|
||||
|
||||
selectedItem: any;
|
||||
totpSettingDisplay = false;
|
||||
|
@ -22,9 +24,9 @@ export class MemberTotpComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
this.lists = [
|
||||
{id: 1, name: 'Email', value: this.member.email, description: 'blabla', },
|
||||
{id: 2, name: 'Phone', value: this.member.phone, description: 'blabla', },
|
||||
{id: 3, name: 'Google 2factor', value: this.member.totpType, description: 'blabla', },
|
||||
{id: 1, name: 'Email', value: this.domainMember.member.email, description: 'blabla', },
|
||||
{id: 2, name: 'Phone', value: this.domainMember.member.phone, description: 'blabla', },
|
||||
{id: 3, name: 'Google 2factor', value: this.domainMember.member.totpType, description: 'blabla', },
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -35,13 +37,13 @@ export class MemberTotpComponent implements OnInit {
|
|||
if (this.selectedItem.id === 3) {
|
||||
this.headerItem = '구글 인증기 설정하기';
|
||||
this.totpSettingDisplay = true;
|
||||
this.totpCreate.emit();
|
||||
this.create.emit(this.domainMember.member);
|
||||
}
|
||||
}
|
||||
|
||||
totpInput(e) {
|
||||
if ( e.target.value.length === 6 ) {
|
||||
this.totpRegist.emit(e.target.value);
|
||||
this.regist.emit(e.target.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<of-member-totp
|
||||
[member]="member"
|
||||
[domainMember]="domainMember$ | async"
|
||||
[totp]="totp$ | async"
|
||||
(totpRegist)="onTotpRegist($event)"
|
||||
(totpCreate)="onTotpCreate()"></of-member-totp>
|
||||
(regist)="regist($event)"
|
||||
(create)="create()"
|
||||
>
|
||||
</of-member-totp>
|
||||
|
|
|
@ -1,53 +1,40 @@
|
|||
import { Component, OnInit} from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import * as TotpStore from '../store/entity/member-totp';
|
||||
import { AuthSelector } from '../store/entity/member';
|
||||
import { Member, MemberTotp } from '@overflow/commons-typescript/model/member';
|
||||
import {Observable} from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
||||
|
||||
import * as TotpEntityStore from '../store/entity/member-totp';
|
||||
import { AuthContainerSelector } from '@overflow/shared/auth/store';
|
||||
|
||||
@Component({
|
||||
selector: 'of-member-totp-container',
|
||||
templateUrl: './member-totp-container.component.html',
|
||||
})
|
||||
export class MemberTotpContainerComponent implements OnInit {
|
||||
member: Member;
|
||||
domainMember$: Observable<DomainMember>;
|
||||
totp$: Observable<MemberTotp[]>;
|
||||
lists = [];
|
||||
|
||||
constructor(private activatedRoute: ActivatedRoute,
|
||||
constructor(
|
||||
private activatedRoute: ActivatedRoute,
|
||||
private router: Router,
|
||||
private store: Store<TotpStore.State>,
|
||||
private store: Store<any>,
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.store.select(AuthSelector.select('member')).subscribe(
|
||||
(member: Member) => {
|
||||
this.member = member;
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
this.domainMember$ = this.store.select(AuthContainerSelector.selectDomainMember);
|
||||
}
|
||||
|
||||
onTotpRegist(obj: any) {
|
||||
regist(info: {member: Member, code: string, secretCode: string}) {
|
||||
const secretCode = 'X6AWAK573M5372NM';
|
||||
|
||||
this.store.dispatch(new TotpStore.Regist({ member: this.member, secretCode: obj.secretCode, code: obj.code }));
|
||||
|
||||
// this.store.select(AuthSelector.select('memberTotp')).subscribe(
|
||||
// (memberTotp: MemberTotp) => {
|
||||
//
|
||||
// },
|
||||
// (error) => {
|
||||
// console.log(error);
|
||||
// }
|
||||
// );
|
||||
this.store.dispatch(new TotpEntityStore.Regist(info));
|
||||
}
|
||||
|
||||
onTotpCreate() {
|
||||
this.store.dispatch(new TotpStore.CreateTotp(this.member));
|
||||
create(member: Member) {
|
||||
this.store.dispatch(new TotpEntityStore.CreateTotp(member));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user