Update pin validation logic

This commit is contained in:
Rene Vergara 2022-05-20 13:41:48 -05:00
parent 916d4a0088
commit 8b1f2b075e
Signed by: pitmutt
GPG Key ID: 65122AD495A7F5B2
2 changed files with 13 additions and 4 deletions

View File

@ -194,8 +194,13 @@ export class LoginComponent implements OnInit, AfterViewInit {
} }
confirmPin(){ confirmPin(){
this.userService.validateUser(this.pinForm.value.pinValue); this.userService.validateUser(this.pinForm.value.pinValue).subscribe((val) => {
this.loginCheck(); if (val) {
this.router.navigate(['/biz']);
} else {
this.pinError = true;
}
});
} }
ngOnDestroy(){ ngOnDestroy(){

View File

@ -124,14 +124,18 @@ export class UserService{
validateUser(pinString:string){ validateUser(pinString:string){
const params = new HttpParams().append('session', this.dataStore.user.session).append('pin', pinString); const params = new HttpParams().append('session', this.dataStore.user.session).append('pin', pinString);
this.http.post(this.beUrl+'api/validateuser', {}, {headers: this.reqHeaders, params: params, observe: 'response'}). let obs = this.http.post(this.beUrl+'api/validateuser', {}, {headers: this.reqHeaders, params: params, observe: 'response'});
subscribe((responseData) => { obs.subscribe((responseData) => {
if (responseData.status == 202) { if (responseData.status == 202) {
console.log('Pin validated!'); console.log('Pin validated!');
return true;
} else { } else {
console.log('Wrong pin!'); console.log('Wrong pin!');
return false;
} }
}); });
return obs;
} }
addOwner(owner: Owner) { addOwner(owner: Owner) {