Currently, I am attempting to log in using Firebase. The login system is functioning correctly; however, I am facing a challenge in retrieving the error name from the authentication service and displaying it in my login component.
SignIn(email: string, password: string) {
this.angularFireAuth
.signInWithEmailAndPassword(email, password)
.then(res => {
console.log('Connected OK');
this.setValueError(false);
this.router.navigate(['/user']);
})
.catch(err => {
console.log('Error:',err.message);
this.setValueError(true);
});
}
setValueError(newValue): void {
this.isError.next(newValue);
}
Below is my retrieval function:
getValueError(): Observable<boolean> {
return this.isError.asObservable();
}
In my login component, I have the following code:
signIn() {
this.authenticationService.SignIn(this.email, this.password);
this.authenticationService.getValueError().subscribe((value) => {
alert(value);
});
this.email = '';
this.password = '';
}
The issue I am encountering is that the alert displays two values. For instance, when there is an error in my login, FALSE and TRUE are displayed.
I am seeking assistance on how to only retrieve the actual value indicating whether there is a login error or not.
Thank you for your help