2018-05-31 12:11:31 +00:00
|
|
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
2018-05-28 11:25:53 +00:00
|
|
|
import { DomainMember } from '@overflow/commons-typescript/model/domain';
|
|
|
|
import { Member } from '@overflow/commons-typescript/model/member';
|
2018-06-01 11:31:46 +00:00
|
|
|
import {AuthSelector} from '../../shared/auth/store';
|
|
|
|
import { Observable, of } from 'rxjs';
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
import * as AuthStore from '@overflow/shared/auth/store/auth';
|
|
|
|
import { catchError, map, tap } from 'rxjs/operators';
|
2018-05-28 10:28:26 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'of-member-totp',
|
|
|
|
templateUrl: './member-totp.component.html',
|
|
|
|
})
|
|
|
|
export class MemberTotpComponent implements OnInit {
|
2018-06-01 11:31:46 +00:00
|
|
|
domainMember: DomainMember;
|
|
|
|
totp;
|
|
|
|
// @Output() regist = new EventEmitter<{ member: Member, code: string, secretCode: string }>();
|
|
|
|
// @Output() create = new EventEmitter<Member>();
|
|
|
|
|
|
|
|
pending$: Observable<boolean>;
|
|
|
|
error$: Observable<any>;
|
2018-05-28 10:28:26 +00:00
|
|
|
|
|
|
|
selectedItem: any;
|
|
|
|
totpSettingDisplay = false;
|
|
|
|
headerItem: string;
|
|
|
|
|
|
|
|
totpCode: string;
|
|
|
|
|
|
|
|
lists = [];
|
|
|
|
|
2018-06-01 11:31:46 +00:00
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
) { }
|
2018-05-28 10:28:26 +00:00
|
|
|
|
|
|
|
ngOnInit() {
|
2018-06-01 11:31:46 +00:00
|
|
|
this.store.select(AuthSelector.selectDomainMember).subscribe(
|
|
|
|
(domainMember: DomainMember) => {
|
|
|
|
this.domainMember = domainMember;
|
|
|
|
}
|
|
|
|
);
|
2018-05-28 10:28:26 +00:00
|
|
|
this.lists = [
|
2018-05-31 12:11:31 +00:00
|
|
|
{ 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', },
|
2018-05-28 10:28:26 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
on2factorConfig(event: Event, item: any) {
|
|
|
|
this.selectedItem = item;
|
|
|
|
|
|
|
|
// server totp regist member info modify
|
|
|
|
if (this.selectedItem.id === 3) {
|
|
|
|
this.headerItem = '구글 인증기 설정하기';
|
|
|
|
this.totpSettingDisplay = true;
|
2018-06-01 09:16:23 +00:00
|
|
|
// this.create.emit(this.domainMember.member);
|
2018-05-28 10:28:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
totpInput(e) {
|
2018-06-01 09:16:23 +00:00
|
|
|
if (e.target.value.length >= 6) {
|
2018-06-01 11:31:46 +00:00
|
|
|
// this.regist.emit(e.target.value);
|
2018-05-28 10:28:26 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|