Exemplo n.º 1
0
        public ActionResult ChangePassword(string oldpassword, string newpassword)
        {
            int            id  = StateHelper.UserId;
            UserDataAccess obj = new UserDataAccess();

            oldpassword = EncryptionHelper.HashString(oldpassword);
            newpassword = EncryptionHelper.HashString(newpassword);
            bool success;
            bool IsCorrectPassword = obj.CheckPassword(id, oldpassword);

            if (IsCorrectPassword == true)
            {
                success = obj.ChangePassword(id, newpassword);
                if (success)
                {
                    return(Json(new { Result = success, Message = CustomMessages.PasswordChanged }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { Result = success, Message = CustomMessages.PasswordNotChanged }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                success = false;
                return(Json(new { Result = success, Message = CustomMessages.PasswordNotCorrect }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public ActionResult UpdatePassword(CHANGEPASSWORD changePassword)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int  userId = (int)Session["ID"];
                    USER user   = userDA.GetById(userId);

                    if (user.PASSWORD == changePassword.OLDPASSWORD)
                    {
                        if (changePassword.NEWPASSWORD == changePassword.NEWPASSWORD_REPEAT)
                        {
                            userDA.ChangePassword(userId, changePassword.NEWPASSWORD);
                            ViewBag.Success = "Şife değiştirildi.";
                            return(View("ChangePassword"));
                        }
                        else
                        {
                            ViewBag.Error = "Yeni şifreler uyuşmuyor.";
                            return(View("ChangePassword"));
                        }
                    }
                    else
                    {
                        ViewBag.Error = "Eski şifre hatalı.";
                        return(View("ChangePassword"));
                    }
                }
                else
                {
                    ViewBag.Error = "Try Again.";
                    return(View("ChangePassword"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Try Again.";
                return(View("ChangePassword"));
            }
        }
Exemplo n.º 3
0
        public DataTable ChangePassword(UserModel objUCModel)
        {
            DataTable dtMatchLoginDetails = objUCDA.ChangePassword(objUCModel);

            return(dtMatchLoginDetails);
        }
Exemplo n.º 4
0
 public int EditPassword(User user)
 {
     return(userDataAccess.ChangePassword(user.UserName, user.Password));
 }