I am currently implementing a confirm email process in my angular 2 application (.net core 2 backend). The workflow currently goes: user registers -> they are sent an email to confirm their account -> they click the link -> they're directed to an angular component that SHOULD read the userId and generated token. The Url in the browser is http://localhost:35000/confirm-email?token=CfDJ8OR7TVlXC69LsUgYal539cq4%2FcxvIXYoyaXcvLXQofMfK8d%2Bp6JE02IBATC49meM8bNSq9pgzq%2B7MspZLt7h1hfetLF2iVkXRkQZHFiJluhRpJbZ7kkafpyrbXjs82KFjkzVSOEDGV4sC6x4%2Bd0i0SXejfK%2F%2FpZgKTnOhdvB%2FwbLK5iauwdDXnjV7ZN7LHA0HInpvBPF2OOpdjJ%2FXicRLYLq5ic4Pz7SnXz0iwOTj4HJQIZAX%2FA1DqgvrPR6vuaOwQ%3D%3D&userId=5da26d4c-f737-481c-9142-affd89e8e9d6
which routes me to the confirm-email component below however I am unable to read my params token and userId properly - they are always undefined. The simplified code for my angular component is below:
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;
});
});
}
}
{}