Beispiel #1
0
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel forgotPasswordViewModel)
        {
            if (this.ModelState.IsValid)
            {
                var user = await this.userIdentityApplicationService.FindByNameAsync(forgotPasswordViewModel.Email);

                if (user == null || !(await this.userIdentityApplicationService.IsEmailConfirmedAsync(user.Id)))
                {
                    var forgotPasswordConfirmationViewModel = new ForgotPasswordConfirmationViewModel(this.userIdentityProvider);

                    // Don't reveal that the user does not exist or is not confirmed.
                    return(this.View(nameof(this.ForgotPasswordConfirmation), forgotPasswordConfirmationViewModel));
                }

                // TODO: Enable account confirmation.

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                // string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
                // var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                // await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");
                // return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            return(this.View(forgotPasswordViewModel));
        }
Beispiel #2
0
        public ActionResult ForgotPasswordConfirmation(ForgotPasswordConfirmationViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    User user;
                    using (var scope = new UnitOfWorkScope())
                    {
                        user = _repository.GetAll().SingleOrDefault(x => x.RegistrationCode == model.UserName);
                        if (user == null)
                        {
                            throw new JsonException("Корисникот не е пронајден во системот.");
                        }
                        user.SetPassword(model.PasswordNew.Md5String());
                        _repository.Update(user);
                        scope.Commit();
                    }
                    return(Json(true));
                }
                catch (Exception ex)
                {
                    if (ex is JsonException)
                    {
                        throw ex;
                    }

                    ModelState.AddModelError(string.Empty,
                                             "Во моментов системот има технички проблеми.<br/>Обидете се повторно за некоја минута");
                    Log.Error(ex);
                }
            }

            throw base.CreateModelException(model);
        }
        public async Task <ActionResult> ForgotPasswordConfirmation(ForgotPasswordConfirmationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (Convert.ToInt32(TempData["OTP"]) == model.OTP)
            {
                var user = await UserManager.FindByNameAsync(TempData["PassEmail"].ToString());

                if (user == null)
                {
                    // Don't reveal that the user does not exist
                    return(View("Error"));
                }
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                var result = await UserManager.ResetPasswordAsync(user.Id, code, model.New_Password);

                if (result.Succeeded)
                {
                    return(RedirectToAction("ResetPasswordConfirmation", "Account"));
                }
                AddErrors(result);
            }
            return(View());
        }
        public IActionResult ForgotPasswordConfirmation([FromQuery] string returnUrl)
        {
            var viewModel = new ForgotPasswordConfirmationViewModel
                            (
                returnUrl
                            );

            return(View(viewModel));
        }
Beispiel #5
0
        public IActionResult ForgotPasswordConfirmation(ForgotPasswordThirdStepViewModel model)
        {
            ForgotPasswordConfirmationViewModel forgotPasswordConfirmationViewModel = new ForgotPasswordConfirmationViewModel()
            {
                UserId = model.UserId
            };

            return(View(forgotPasswordConfirmationViewModel));
        }
Beispiel #6
0
        public async Task <IActionResult> ForgotPasswordConfirmation(ForgotPasswordConfirmationViewModel model)
        {
            User user = await _userService.GetById(model.UserId);

            await _userService.ResetPassword(user, model.NewPassword);

            await _mailService.PasswordChange(user.Email, "Your password has been updated!");

            ViewData["PasswordResetedSuccessfully"] = "Password has been reseted successfully";
            return(View());
        }
Beispiel #7
0
        public async Task <ActionResult> ForgotPasswordConfirmation(ForgotPasswordConfirmationViewModel model)
        {
            var user = await UserManager.FindByNameAsync(model.user);

            if (user != null)
            {
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                if (code == model.Code)
                {
                }
            }
            return(View());
        }
Beispiel #8
0
        public ActionResult ForgotPasswordConfirmation()
        {
            var forgotPasswordConfirmationViewModel = new ForgotPasswordConfirmationViewModel(this.userIdentityProvider);

            return(this.View(forgotPasswordConfirmationViewModel));
        }