I'm trying to reset a user's password (create a new one) in this "enter new password" screen, right after the user receiving an email with a token. In my component I use the ActivateRoute to grab the params in the url (token, email, password) and I need these params to send them to the API, but so far, I get "undefined", right on the component. This is the ActivateRoute:
export class NewPasswordComponent implements OnInit {
public loginValues = new User([]);
// Constructor & init
constructor(
private auth: AuthService,
private router: Router,
private userService: UserService,
private snackBar: MatSnackBar,
private activatedRoute: ActivatedRoute,
) {
this.activatedRoute.params.subscribe(params => {
console.log(params['email']);
console.log(params.email); -> undefined
this.loginValues.email = params['email'];
this.loginValues.token = params['token'];
});
}
The component method that comunicates with the service (called on submit new password in the HTML)
clientNewPassword() {
this.userService.newPassword(this.loginValues, passwordSent => {
this.router.navigateByUrl('/login');
});
}
The service:
public newPassword(user: User, callback: (passwordSent: User) => void) {
return this.restangular
.all('auth/reset')
.customPOST(user.toJSONNewPassword())
.map((res) => res.data)
.subscribe({
next: (res: User) => {
this.user = new User(res);
callback(this.user);
},
});
}
And the Routes:
//NEW PASSWORD
{
path: 'new-password/:email:token',
component: NewPasswordComponent,
canActivate: [LoginGuard],
},
Can someone help me achieve this? Thanks
EDIT:
The URL I'm trying to call:
http://localhost:4200/new-password/email=snapexpress@gmail.com;token=13af5d409878f1dd5ec88049ba82a5549a07deb4