Correct PIN processing

This commit is contained in:
Rene Vergara 2022-05-20 09:47:17 -05:00
parent d6f48a8338
commit 55ee54cd4f
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 9 additions and 11 deletions

View file

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

View file

@ -122,12 +122,14 @@ export class UserService{
} }
} }
validateUser(){ validateUser(pinString:string){
var validatedUser: User = this.dataStore.user; this.http.post(this.beUrl+'api/validateuser', {pin: pinString, session: this.dataStore.user.session}, {headers: this.reqHeaders, observe: 'response'}).
validatedUser.validated = true;
this.http.post<{message: string, user: User}>(this.beUrl+'api/validateuser', {user: validatedUser}, {headers: this.reqHeaders}).
subscribe((responseData) => { subscribe((responseData) => {
console.log(responseData.message); if (responseData.status == 202) {
console.log('Pin validated!');
} else {
console.log('Wrong pin!');
}
}); });
} }