I have a method for authentication that is kept private. Additionally, I have a public method named login
which is utilized in my components to carry out the actual login process. I am interested in subscribing to the login
method, which internally subscribes to the private authentication
method. This will allow me to display loading messages and handle errors uniquely based on different views. Is this achievable?
This is the Authentication method:
private userAuthenticate( email: string, password: string ) {
return this.httpPost(`${this.baseApiUrl}/auth?format=json&provider=login`, {userName: email, password: password}).subscribe(
res => this.saveJwt(res.bearerToken),
err => this.logError(err),
() => console.log("Authentication done.")
);
}
This is the Login method:
login( email: string, password: string ) {
this.logout();
return this.userAuthenticate(email, password);
}
I aim to subscribe to the login method to manage loaders and error messages accordingly. I appreciate any assistance.