I'm testing a webapi that sends email with a link for user verification, I receive the email, but when I click the link, it does not verify the user via the email link, instead I get the below error
No webpage was found for the web address: http://localhost:4000/account/verify-email?token={token}
see below code in controller for the verification
[HttpPost("verify-email")]
public IActionResult VerifyEmail(VerifyEmailRequest model)
{
_accountService.VerifyEmail(model.Token);
return Ok(new { message = "Verification successful, you can now login" });
}
see code in services class
public void VerifyEmail(string token)
{
var account = _context.Accounts.SingleOrDefault(x => x.VerificationToken == token);
if (account == null) throw new AppException("Verification failed");
account.Verified = DateTime.UtcNow;
account.VerificationToken = null;
_context.Accounts.Update(account);
_context.SaveChanges();
}
CodePudding user response:
Code true working, You need check http://localhost:4000/account/verify-email?token={token} url.
You send this url. Your project working in Localhost:4000?
CodePudding user response:
Make sure you have:
[Route("account")]
At the top