I have a private method which i use for authentication. Then i have another method (public) that i call in my components called login
to do the actual login. I want to be able to subscribe to the login
method which in reality subscribe's to the private authentication
method so that i can show loading and other messages while login in being performed differently for each view. Is it possible?
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.")
);
}
Login method:
login( email: string, password: string ) {
this.logout();
return this.userAuthenticate(email, password);
}
I want to subscribe to the login method so that i can control my loaders and error messages etc. Please help.