I'm new to Angular and I'm creating a forgot password link, which when the user interacts with it will send out an email to their email address with a unique password token in order so they can reset their password. I want to be able to recognize the user, using their user identifier and match their email address with this and send out the email.
- Do I need to pass in the user identifier or user email address into the service?
- How do I structure the ngOnInit?
// user.service.ts
public forgotUserPasswordVerification(email: string): Observable<void> { // email or identifier??
return this.http.post<void>('api/verifications/forgotpasswordverification', email);
}
// forgot-password.component.ts
ngOnInit() {
this.userService.forgotUserPasswordVerification(this.email) // this.email or this.identifier?
.subscribe(data => {
this.success = true;
})};
I don't see a need to create a component for this. Try to implement this logic inside the userService:
Pass the user ID to your forgotUserPasswordVerification(userId) method, inside it you should be able to do 2 operations: first
then
And call this your forgotUserPasswordVerification(userId) method in the login component once the user click the link.