Exemple #1
0
        public async Task <IActionResult> OnPostResendEmail(int userId)
        {
            var user = await _userManager.FindByIdAsync(userId.ToString());

            string emailResendResult = "";

            if (user != null)
            {
                try
                {
                    await _emailConfirm.TrySendConfirmationEmail(user, Request, Url);

                    emailResendResult = "We have resent the confirmation email. Remember to check your spam folder. If you still do not recieve the email, please contact your supervisor.";
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.Message);
                    emailResendResult = "Error: Something went wrong when attempting to send the confirmation email, please contact your supervisor.";
                }

                return(RedirectToPage("/Account/Login", new { statusMessage = emailResendResult }));
            }
            else
            {
                emailResendResult = "Error: Something went wrong when attempting to send the confirmation email, please contact your supervisor.";
                return(RedirectToPage("/Account/Login", new { statusMessage = emailResendResult }));
            }
        }
        public async Task <IActionResult> OnPostResendEmail(int id)
        {
            var user = await _userManager.FindByIdAsync(id.ToString());

            await _emailConfirm.TrySendConfirmationEmail(user, this.Request, this.Url);

            return(RedirectToPage("/Account/Login", new { statusMessage = "We have sent you another confirmation email. Please check your inbox or spam/junk folder." }));
        }
 private async Task TrySendConfirmationEmail(AppUser user)
 {
     try
     {
         await _emailConfirm.TrySendConfirmationEmail(user, Request, Url);
     }
     catch (Exception ex)
     {
         _logger.LogError("Email confirmation failed to send. Error: " + ex.ToString());
     }
 }