Base solution for your next web application
Open Closed

Implementing Email Confirmation #1587


User avatar
0
patrickloui created

Hello, i'm trying to implement email confirmation for the account registration, i'm currently having trouble with

_usermanager.ConfirmEmailAsync(userId,code);

it always returns

{UserId not found}

Here is my implementation of email sending:

var provider = new DpapiDataProtectionProvider("APP");
 _userManager.UserTokenProvider = new DataProtectorTokenProvider<User, long(provider.Create("EmailConfirmation")) as IUserTokenProvider<User, long>;

string code = await _userManager.GenerateEmailConfirmationTokenAsync(adminUser.Id);
var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = adminUser.Id, code = code }, protocol: Request.Url.Scheme);

await _emailSender.SendAsync(adminUser.EmailAddress,"Account Confirmation", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>",true);

Thank you in advance.


1 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Are you using multitenancy? IF so, you may need to the correct tenant before using usermanager.