So in my /xyz.component.ts, I'm calling the resetPassword method from /user.ts. In the LoopBack documentation it says:
Calling User.resetPassword ultimately emits a resetPasswordRequest event and creates a temporary access token.
But how do I catch the event? If I try to apply .on('resetPasswordRequest', ()=>{....}) it tells me there is no 'on' for the UserApi.
/xyz.component.ts
private resetPassword(){
this.userApi.resetPassword({email: this.userName}).subscribe((data : any)=>{
console.log(data);
},(error : any) => {
this.error = error;
}
);
console.log("error: " , this.error);
}
/user.ts
public resetPassword(options: any, customHeaders?: Function): Observable<any> {
let _method: string = "POST";
let _url: string = LoopBackConfig.getPath() + "/" + LoopBackConfig.getApiVersion() +
"/Users/reset";
let _routeParams: any = {};
let _postBody: any = {
options: options
};
let _urlParams: any = {};
let result = this.request(_method, _url, _routeParams, _urlParams, _postBody, null, customHeaders);
return result;
}
MROALI was so kind to help me out with my question on GitHub. So, what you need to do to catch the 'resetPasswordRequest' Event is editing the constructor of your User Model (or extendend User Model, if you're not using the default) like so:
constructor(public model: any) {
model.on('resetPasswordRequest', function (info:any) {
console.log("do something");
})
}