member_webapp/@overflow/member/container/member-totp-container.component.ts

54 lines
1.4 KiB
TypeScript
Raw Normal View History

2018-05-28 10:28:26 +00:00
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';
@Component({
selector: 'of-member-totp-container',
templateUrl: './member-totp-container.component.html',
})
export class MemberTotpContainerComponent implements OnInit {
member: Member;
totp$: Observable<MemberTotp[]>;
lists = [];
constructor(private activatedRoute: ActivatedRoute,
private router: Router,
private store: Store<TotpStore.State>,
) { }
ngOnInit() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
this.member = member;
},
(error) => {
console.log(error);
}
);
}
onTotpRegist(obj: any) {
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);
// }
// );
}
onTotpCreate() {
this.store.dispatch(new TotpStore.CreateTotp(this.member));
}
}