Exemple #1
0
        public async Task <IActionResult> ForgotPassword(string email)
        {
            if (ModelState.IsValid)
            {
                var user = await Identities.GetUserByUsernameAsync(email);

                if (user == null)
                {
                    return(RedirectToAction("ForgotPasswordConfirm"));
                }

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=532713
                // Send an email with this link
                var result = await Identities.GeneratePasswordResetTokenAsync(user);

                var callbackUrl = Url.Action("ForgotPasswordCallback", "Account", new { userId = user.Id, code = result.Token }, HttpContext.Request.Scheme);
                await Communication.SendForgotPassword(user, callbackUrl);

                return(RedirectToAction("ForgotPasswordConfirm"));
            }
            else
            {
                var invalidProperty = ModelState.First(x => x.Value.ValidationState == ModelValidationState.Invalid);
                SetUserError("תקלה במידע שהתקבל", invalidProperty.Value.Errors.FirstOrDefault()?.ErrorMessage ?? "אנא נסו שוב");
                return(View());
            }
        }