public IActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            LoginCacheItem loginCacheItem = GetCachedLoginAttempt(true);

            if (!String.IsNullOrEmpty(loginCacheItem.CaptchaText))
            {
                if (!loginCacheItem.CaptchaText.Equals(model.CaptchaText))
                {
                    ModelState.AddModelError(String.Empty, Languages.LanguageStrings.CodeNotValid);
                }
            }

            if (ModelState.IsValid && _loginProvider.ForgottenPassword(model.Username))
            {
                RemoveLoginAttempt();
                return(Redirect("/Login/"));
            }

            ModelState.AddModelError(String.Empty, Languages.LanguageStrings.InvalidUsernameOrPassword);

            loginCacheItem.CaptchaText = GetRandomWord(_settings.CaptchaWordLength, CaptchaCharacters);
            model.CaptchaText          = loginCacheItem.CaptchaText;
            model.Breadcrumbs          = GetBreadcrumbs();
            model.CartSummary          = GetCartSummary();

            return(View(model));
        }
        public IActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            LoginCacheItem loginCacheItem = GetCachedLoginAttempt(true);

            if (!String.IsNullOrEmpty(loginCacheItem.CaptchaText))
            {
                if (!loginCacheItem.CaptchaText.Equals(model.CaptchaText))
                {
                    ModelState.AddModelError(String.Empty, "Invalid Validation Code");
                }
            }

            if (ModelState.IsValid && _loginProvider.ForgottenPassword(model.Username))
            {
                RemoveLoginAttempt();
                return(Redirect("/Login/"));
            }

            ModelState.AddModelError(String.Empty, "The details you provided could not be validated.");

            loginCacheItem.CaptchaText = GetRandomWord(_settings.CaptchaWordLength, CaptchaCharacters);
            model.CaptchaText          = loginCacheItem.CaptchaText;

            return(View(model));
        }