public async Task <IActionResult> ResendMail() { AccountStatusPair asp = await repository.GetAccountStatus(Request, Response); if (asp.status != AccountStatus.Inactive) { return(RedirectToAction("Index")); } asp.account.VerificationCode = ActivateModel.GenerateCode(); repository.ForceSave(); try { // Services.Email.SendVerification(userAccount.Email, userAccount.VerificationCode.ToString(), "A new verification code was requested."); } catch (Exception ex) { logger.LogError($"AUTO-MAIL FAILED: {ex.Message}"); return(RedirectToAction("Error")); } logger.LogInformation($"User @{asp.account.Username} (ID: {asp.account.Id}) requested a new verification code to email {asp.account.Email} (Verification code: {asp.account.VerificationCode})"); return(RedirectToAction("Activate", new { Resent = true })); }