Ejemplo n.º 1
0
        public async Task <ForgotPasswordResetResult> ResendConfirmationAsync(ForgotPasswordModel model)
        {
            var userEmail      = model.Email;
            var isVerifiedUser = await _identityProvider.VerifyUserExists(userEmail);

            if (!isVerifiedUser)
            {
                return(ForgotPasswordResetResult.BadEmail(userEmail));
            }

            var isConfirmed = await _identityProvider.VerifyUserEmailConfirmed(userEmail);

            if (isConfirmed)
            {
                var message = string.Format(
                    "The account with email address '{0}' has already been confirmed.  Use the password reset if the password has been lost.",
                    userEmail);

                return(new ForgotPasswordResetResult
                {
                    Success = false,
                    Message = message
                });
            }

            var secret = await _identityProvider.GenerateEmailConfirmationToken(userEmail);

            try
            {
                _emailService.SendConfirmationEmail(userEmail, secret);
            }
            catch (Exception e)
            {
                _log.Error("SendEmail", e);
                return(EmailDown <ForgotPasswordResetResult>());
            }

            return(ForgotPasswordResetResult.Successful);
        }