diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 9b64a72..2e740a8 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -194,8 +194,13 @@ export class LoginComponent implements OnInit, AfterViewInit { } confirmPin(){ - this.userService.validateUser(this.pinForm.value.pinValue); - this.loginCheck(); + this.userService.validateUser(this.pinForm.value.pinValue).subscribe((val) => { + if (val) { + this.router.navigate(['/biz']); + } else { + this.pinError = true; + } + }); } ngOnDestroy(){ diff --git a/src/app/user.service.ts b/src/app/user.service.ts index ebae554..39e00bf 100644 --- a/src/app/user.service.ts +++ b/src/app/user.service.ts @@ -124,14 +124,18 @@ export class UserService{ validateUser(pinString:string){ 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'}). - subscribe((responseData) => { + let obs = this.http.post(this.beUrl+'api/validateuser', {}, {headers: this.reqHeaders, params: params, observe: 'response'}); + obs.subscribe((responseData) => { if (responseData.status == 202) { console.log('Pin validated!'); + return true; } else { console.log('Wrong pin!'); + return false; } }); + + return obs; } addOwner(owner: Owner) {