Esempio n. 1
0
        // GET: PasswordReset
        public async Task <ActionResult> Process(ForgotPasswordModel resetPasswordModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var result = _verify.ValidateEmailIdExists(resetPasswordModel.EmailId);

                    if (!result)
                    {
                        TempData["PasswordResetMessage"] = "In Valid EmailId";
                    }
                    else
                    {
                        SendingEmailhelper sendingEmailhelper = new SendingEmailhelper();
                        var generatecode   = GenerateHashSha256.ComputeSha256Hash(GenerateRandomNumbers.RandomNumbers(6));
                        var userId         = _userMaster.GetUserIdbyEmailId(Convert.ToString(resetPasswordModel.EmailId));
                        var count          = _verification.GetSentResetPasswordVerificationCount(userId);
                        var sentEmailCount = Convert.ToInt32(ConfigurationManager.AppSettings["MaxResetEmailCount"]);
                        if (count == sentEmailCount)
                        {
                            TempData["PasswordResetMessage"] = "You Have exceed Limit for Resetting Password";
                        }
                        else
                        {
                            _verification.SendResetVerificationToken(userId, generatecode);
                            TempData["PasswordResetMessage"] = "Email Sent to your Account";
                            await sendingEmailhelper.SendForgotPasswordVerificationEmailasync(resetPasswordModel.EmailId, generatecode, "ForgotPassword", userId.ToString());
                        }
                    }
                }
                return(View(resetPasswordModel));
            }
            catch (Exception)
            {
                throw;
            }
        }