Example #1
0
 public void TestResetPasswordFail()
 {
     PasswordResetRequestModel prrModel = new PasswordResetRequestModel();
     prrModel.Email = "*****@*****.**";
     RedirectToRouteResult result = (RedirectToRouteResult)usersController.ResetPassword(prrModel);
     Assert.IsTrue(result.RouteValues.ContainsValue("There is no registered user in DREAM with that email."));
 }
Example #2
0
        public ActionResult ResetPassword(PasswordResetRequestModel passwordResetRequestModel)
        {
            RouteValueDictionary rVDictionary = new RouteValueDictionary();

            if (ModelState.IsValid)
            {
                String username = Membership.GetUserNameByEmail(passwordResetRequestModel.Email);

                if (username != null)
                {
                    MembershipUser user = Membership.GetUser(username);

                    try
                    {
                        PasswordResetRequest.GenerateFor(user);
                        rVDictionary.Add("email", passwordResetRequestModel.Email);
                        rVDictionary.Add("success", true);
                        rVDictionary.Add("statusMessage", "Password Reset Successfully");
                        return RedirectToAction("Index", "Home", rVDictionary);
                    }
                    catch
                    {
                        ModelState.AddModelError(passwordResetRequestModel.Email, "Error in trying to reset password for user.");
                        rVDictionary.Add("email", passwordResetRequestModel.Email);
                        rVDictionary.Add("success", false);
                        rVDictionary.Add("statusMessage", "Error in trying to reset password for user.");
                        return View(passwordResetRequestModel);
                    }
                }
                else
                {
                    ModelState.AddModelError(passwordResetRequestModel.Email, "This user does not exist in the DREAM system.");
                    rVDictionary.Add("email", "");
                    rVDictionary.Add("success", false);
                    rVDictionary.Add("statusMessage", "There is no registered user in DREAM with that email.");
                    return RedirectToAction("ResetPassword", "Users", rVDictionary);
                }
            }
            else
            {
                ModelState.AddModelError("", "ModelState is not valid");
                return View(passwordResetRequestModel);
            }
        }
Example #3
0
 public void TestResetPassword()
 {
     PasswordResetRequestModel prrModel = new PasswordResetRequestModel();
     prrModel.Email = "*****@*****.**";
     RedirectToRouteResult result = (RedirectToRouteResult)usersController.ResetPassword(prrModel);
     Assert.IsTrue(result.RouteValues.ContainsValue("Password Reset Successfully"));
 }
Example #4
0
 public ActionResult ResetPassword(String email, String statusMessage, bool success = false)
 {
     PasswordResetRequestModel passwordResetRequestModel = new PasswordResetRequestModel();
     passwordResetRequestModel.Email = email;
     ViewBag.success = success;
     ViewBag.StatusMessage = statusMessage;
     return View();
 }