I am using AWS SES service to send email to users. Upon registration, a token is generated in my AccountServive.sc
var confirmEmailToken = await _userManager.GenerateEmailConfirmationTokenAsync(user);
I have a function in this service SendEmailForAccountCreatedAndEmailVerification
which takes the username, and link to replace the HTML body for an email. And this body is passed in the EmailSender function.
How to create link from this token that the user receives in his/her mail which can be clicked to confirm is email address?
The full code for generating activation link already defined under Register.cshtml.cs
and RegisterConfirmation.cshtml.cs
:
var userId = await _userManager.GetUserIdAsync(user);
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
EmailConfirmationUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { area = "Identity", userId = userId, code = code },
protocol: Request.Scheme);