This commit is contained in:
geek 2018-04-19 22:29:06 +09:00
parent 7a9ee9ed9e
commit 6b65842eec
5 changed files with 18 additions and 8 deletions

View File

@ -16,7 +16,10 @@
</div>
<div>
<p>Key & Backup Code</p>
<div>{{totpMap.key}}</div>
<div *ngIf="totp">{{totp.key}}, {{totp.uri}}</div>
<div *ngIf="totp">
<qrcode [qrdata]="totp.uri" [size]="128" [level]="'M'"></qrcode>
</div>
<form fxLayout="column" fxLayoutAlign="start stretch" [formGroup]="totpForm" (ngSubmit)="totpRegistClick()">
<input type="text"
id="code" class="input"

View File

@ -25,8 +25,9 @@ import {RPCClientError} from '../../../../../../@loafer/ng-rpc/protocol';
export class ConfigSettingComponent implements OnInit, AfterContentInit {
member: Member;
totpState$ = this.store.pipe(select(TotpSelector.select('totp')));
totpMap: any;
totp: any;
totpForm: FormGroup;
qrData:string;
@Input() selectedItem: any;
@Output() close = new EventEmitter();
@ -39,11 +40,16 @@ export class ConfigSettingComponent implements OnInit, AfterContentInit {
) { }
ngOnInit() {
this.totpForm = this.formBuilder.group({
'code': [
[
]
]
});
this.totpState$.subscribe(
(m: any) => {
if (m != null) {
this.totpMap = m;
}
(obj: any) => {
console.log(obj);
this.totp = obj;
},
(error: RPCClientError) => {
console.log(error.response.message);

View File

@ -14,8 +14,6 @@ export class MemberTotpService {
}
public createTotp(member: Member): Observable<MemberTotp[]> {
// Todo Store get member object
return this.rpcService.call<MemberTotp[]>('MemberTotpService.createTotp', member);
}

View File

@ -23,6 +23,7 @@ export function reducer(state = initialState, action: Actions): State {
const keyURI = action.payload.uri;
return {
...state,
totp: {key: secretKey, uri: keyURI},
error: null,
pending: false,
secretKey: secretKey,

View File

@ -1,6 +1,7 @@
import { RESTClientError } from '@loafer/ng-rest/protocol';
export interface State {
totp: any;
secretKey: string;
keyURI: string;
error: RESTClientError | null;
@ -8,6 +9,7 @@ export interface State {
}
export const initialState: State = {
totp: null,
secretKey: null,
keyURI: null,
error: null,