totp store modify ing...
This commit is contained in:
parent
89bbf5dee9
commit
a38df70dd2
|
@ -3,9 +3,12 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||||
import * as TotpStore from '../../store/totp';
|
import * as TotpStore from '../../store/totp';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
|
||||||
|
import { AuthSelector } from 'packages/member/store';
|
||||||
|
|
||||||
|
|
||||||
import { TotpSelector } from '../../store';
|
import { TotpSelector } from '../../store';
|
||||||
import {AuthSelector} from "../../../../member/store/index";
|
import { Member } from 'packages/member/model/Member';
|
||||||
import {Member} from "../../../../member/model/Member";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'of-totp',
|
selector: 'of-totp',
|
||||||
|
@ -51,6 +54,29 @@ export class TotpComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ngAfterContentInit() {
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// }
|
||||||
registClick() {
|
registClick() {
|
||||||
const code = this.totpForm.value['code'];
|
const code = this.totpForm.value['code'];
|
||||||
const secretCode = 'X6AWAK573M5372NM';
|
const secretCode = 'X6AWAK573M5372NM';
|
||||||
|
|
|
@ -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.rpcClient.call<MemberTotp[]>('MemberTotpService.createTotp', {Member: {id:1}});
|
return this.rpcClient.call<MemberTotp[]>('MemberTotpService.createTotp', {Member: member});
|
||||||
}
|
}
|
||||||
|
|
||||||
public regist(member: Member, secretCode: string, code: string): Observable<boolean> {
|
public regist(member: Member, secretCode: string, code: string): Observable<boolean> {
|
||||||
|
@ -27,4 +27,8 @@ export class MemberTotpService {
|
||||||
// };
|
// };
|
||||||
return this.rpcClient.call<boolean>('MemberTotpService.regist', member, secretCode, code);
|
return this.rpcClient.call<boolean>('MemberTotpService.regist', member, secretCode, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public checkCodeForMember(member: Member, code: string): Observable<boolean> {
|
||||||
|
return this.rpcClient.call<boolean>('MemberTotpService.checkCodeForMember', member, code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,10 @@ export enum ActionType {
|
||||||
Regist = '[member.totp] Regist',
|
Regist = '[member.totp] Regist',
|
||||||
RegistSuccess = '[member.totp] RegistSuccess',
|
RegistSuccess = '[member.totp] RegistSuccess',
|
||||||
RegistFailure = '[member.totp] RegistFailure',
|
RegistFailure = '[member.totp] RegistFailure',
|
||||||
|
|
||||||
|
CheckCodeForMember = '[member.totp] CheckCodeForMember',
|
||||||
|
CheckCodeForMemberSuccess = '[member.totp] CheckCodeForMemberSuccess',
|
||||||
|
CheckCodeForMemberFailure = '[member.totp] CheckCodeForMemberFailure',
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateTotp implements Action {
|
export class CreateTotp implements Action {
|
||||||
|
@ -52,6 +56,26 @@ export class RegistFailure implements Action {
|
||||||
constructor(public payload: RESTError) {}
|
constructor(public payload: RESTError) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export class CheckCodeForMember implements Action {
|
||||||
|
readonly type = ActionType.CheckCodeForMember;
|
||||||
|
|
||||||
|
constructor(public payload: {member: Member, code: string}) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CheckCodeForMemberSuccess implements Action {
|
||||||
|
readonly type = ActionType.CheckCodeForMemberSuccess;
|
||||||
|
|
||||||
|
constructor(public payload: void) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CheckCodeForMemberFailure implements Action {
|
||||||
|
readonly type = ActionType.CheckCodeForMemberFailure;
|
||||||
|
|
||||||
|
constructor(public payload: RESTError) {}
|
||||||
|
}
|
||||||
|
|
||||||
export type Actions =
|
export type Actions =
|
||||||
| CreateTotp
|
| CreateTotp
|
||||||
| CreateTotpSuccess
|
| CreateTotpSuccess
|
||||||
|
@ -59,4 +83,7 @@ export type Actions =
|
||||||
| Regist
|
| Regist
|
||||||
| RegistSuccess
|
| RegistSuccess
|
||||||
| RegistFailure
|
| RegistFailure
|
||||||
|
| CheckCodeForMember
|
||||||
|
| CheckCodeForMemberSuccess
|
||||||
|
| CheckCodeForMemberFailure
|
||||||
;
|
;
|
||||||
|
|
|
@ -26,6 +26,10 @@ import {
|
||||||
RegistSuccess,
|
RegistSuccess,
|
||||||
RegistFailure,
|
RegistFailure,
|
||||||
|
|
||||||
|
CheckCodeForMember,
|
||||||
|
CheckCodeForMemberSuccess,
|
||||||
|
CheckCodeForMemberFailure,
|
||||||
|
|
||||||
ActionType,
|
ActionType,
|
||||||
} from './totp.action';
|
} from './totp.action';
|
||||||
|
|
||||||
|
@ -56,14 +60,6 @@ export class Effects {
|
||||||
return of(new CreateTotpFailure(error));
|
return of(new CreateTotpFailure(error));
|
||||||
});
|
});
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
|
||||||
createTotpSuccess$ = this.actions$
|
|
||||||
.ofType(ActionType.CreateTotpSuccess)
|
|
||||||
.do(() => {
|
|
||||||
// Todo TOTP View Print
|
|
||||||
this.router.navigateByUrl(this._returnURL);
|
|
||||||
});
|
|
||||||
|
|
||||||
@Effect()
|
@Effect()
|
||||||
regist: Observable<Action> = this.actions$
|
regist: Observable<Action> = this.actions$
|
||||||
.ofType(ActionType.Regist)
|
.ofType(ActionType.Regist)
|
||||||
|
@ -78,4 +74,20 @@ export class Effects {
|
||||||
.catch((error: RESTError) => {
|
.catch((error: RESTError) => {
|
||||||
return of(new RegistFailure(error));
|
return of(new RegistFailure(error));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@Effect()
|
||||||
|
checkCodeForMember: Observable<Action> = this.actions$
|
||||||
|
.ofType(ActionType.CheckCodeForMember)
|
||||||
|
.map((action: Regist) => action.payload)
|
||||||
|
.switchMap((payload) => {
|
||||||
|
// this._returnURL = payload.returnURL;
|
||||||
|
return this.memberTotpService.checkCodeForMember(payload.member, payload.code);
|
||||||
|
})
|
||||||
|
.map((result: any) => {
|
||||||
|
return new CheckCodeForMemberSuccess(result);
|
||||||
|
})
|
||||||
|
.catch((error: RESTError) => {
|
||||||
|
return of(new CheckCodeForMemberFailure(error));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user