Currently in the process of setting up a confirmation email system for my Angular 2 application with a .NET Core 2 backend. The flow goes like this: user registers -> an email is sent to confirm their account -> they click the link -> they should be directed to an Angular component that is supposed to retrieve the userId and generated token. However, when I navigate to the URL
http://localhost:35000/confirm-email?token=CfDJ8OR7TVlXC69LsUgYal539cq4%2FcxvIXYoyaXcvLXQofMfK8d%2Bp6JE02IBATC49meM8bNSq9pgzq%2B7MspZLt7h1hfetLF2iVkXRkQZHFiJluhRpJbZ7kkafpyrbXjs82KFjkzVSOEDGV4sC6x4%2Bd0i0SXejfK%2F%2FpZgKTnOhdvB%2FwbLK5iauwdDXnjV7ZN7LHA0HInpvBPF2OOpdjJ%2FXicRLYLq5ic4Pz7SnXz0iwOTj4HJQIZAX%2FA1DqgvrPR6vuaOwQ%3D%3D&userId=5da26d4c-f737-481c-9142-affd89e8e9d6
This takes me to the confirm-email component as expected, but I'm having trouble properly reading the parameters token
and userId
- they always show up as undefined. Here's a simplified version of the code for my Angular component:
export class ConfirmEmailComponent implements OnInit {
emailConfirmed: boolean = false;
constructor(private userService: UserService,
private router: Router,
private activatedRoute: ActivatedRoute) { }
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
let token = params['token'];
let userId = params['userId'];
this.userService.confirmEmail(token, userId).subscribe(
(data) => {
this.emailConfirmed = true;
});
});
}
}