Пример #1
0
 public JsonResult ChangePassword(string oldPassword, string newPassword)
 {
     if (string.IsNullOrEmpty(oldPassword))
     {
         return(Json(new { Error = 1, Message = "請輸入舊密碼" }));
     }
     if (string.IsNullOrEmpty(newPassword))
     {
         return(Json(new { Error = 1, Message = "請輸入新密碼" }));
     }
     try
     {
         var          oldPass      = MD5Hash.GetMd5String(oldPassword);
         AdminUserBLL adminUserBll = new AdminUserBLL();
         var          oriPass      = adminUserBll.GetPassHashByUserID(UserID);
         if (!string.Equals(oriPass, oldPass, StringComparison.OrdinalIgnoreCase))
         {
             return(Json(new { Error = 1, Message = "舊密碼錯誤" }));
         }
         var flag = adminUserBll.UpdatePassWordByUserID(UserID, newPassword);
         if (flag)
         {
             return(Json(new { Error = 0 }));
         }
         else
         {
             return(Json(new { Error = 1, Message = "密碼修改失敗" }));
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
         return(Json(new { Error = 1, Message = ex.Message }));
     }
 }
Пример #2
0
 public JsonResult ChangePassword(string oldPassword, string newPassword)
 {
     if (string.IsNullOrEmpty(oldPassword))
     {
         return(Json(new { Error = 1, OldPassword = "******" }));
     }
     if (string.IsNullOrEmpty(newPassword))
     {
         return(Json(new { Error = 1, NewPassword = "******" }));
     }
     try
     {
         var oldPass = MD5Hash.GetMd5String(oldPassword);
         var oriPass = SupplierUserBll.GetPassHashByUserID(CurrentUser.ID);
         if (!string.Equals(oriPass, oldPass, StringComparison.OrdinalIgnoreCase))
         {
             return(Json(new { Error = 1, OldPassword = "******" }));
         }
         var flag = SupplierUserBll.UpdatePassWordByUserID(CurrentUser.ID, newPassword) > 0;
         if (flag)
         {
             return(Json(new { Error = 0 }));
         }
         else
         {
             return(Json(new { Error = 1, Message = "密码修改失败" }));
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
         return(Json(new { Error = 1, Message = ex.Message }));
     }
 }
Пример #3
0
        public void UpdateSupplierInfo(SupplierInfoJsonModel supplierInfo, string userName)
        {
            if (!String.IsNullOrWhiteSpace(supplierInfo.PassWord))
            {
                supplierInfo.PassWord = MD5Hash.GetMd5String(supplierInfo.PassWord);
            }

            supplierInfoDAL.UpdateSupplierInfo(supplierInfo, userName);
        }
Пример #4
0
 public static bool SaveSupplierUserInfo(int supplierID, SupplierUserInfo user)
 {
     try
     {
         user.Password = MD5Hash.GetMd5String(user.Password);
         return(supplierUserDAL.SaveSupplierUserInfo(supplierID, user));
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
     }
     return(false);
 }
Пример #5
0
        /// <summary>
        /// 使用账号和密码登录
        /// </summary>
        /// <returns></returns>
        public LoginUserModel GetLoginUserByLogin(string userName, string password)
        {
            LoginUserModel loginUserModel = null;

            AdminUserInfo userInfo = adminUserDAL.GetByPassword(userName, MD5Hash.GetMd5String(password));

            if (userInfo != null)
            {
                if (userInfo.Status == 1)
                {
                    var loginTime = DateTime.Now;
                    userInfo.LastLoginTime = loginTime;
                    adminUserDAL.UpdateUserLastLoginTime(userInfo.id, loginTime);
                }
                loginUserModel = GetUserPermission(userInfo);
            }

            return(loginUserModel);
        }
Пример #6
0
        public static SupplierUserInfo GetUserInfoByLogin(string userName, string password)
        {
            var loginTime = DateTime.Now;
            var passHash  = MD5Hash.GetMd5String(password);
            var userInfo  = supplierUserDAL.GetUserInfoByLogin(userName);

            if (userInfo != null)
            {
                if (!string.Equals(userInfo.Password, passHash, StringComparison.OrdinalIgnoreCase))
                {
                    supplierUserDAL.IncrementSupplierCounter(userInfo.ID, 0, loginTime.Date);
                    userInfo = null;
                }
                else if (userInfo.SupplierStatus == 1 && userInfo.Status == 1)
                {
                    userInfo.LastLoginTime = loginTime;
                    supplierUserDAL.UpdateUserLastLoginTime(userInfo.ID, loginTime);
                    GetSupplierLogo(userInfo);
                }
            }
            return(userInfo);
        }
Пример #7
0
 public bool SaveAdminUserInfo(AdminUserInfo user)
 {
     user.password = MD5Hash.GetMd5String(user.password);
     return(adminUserDAL.SaveAdminUserInfo(user));
 }
Пример #8
0
 public bool UpdatePassWordByUserID(int userID, string password)
 {
     return(adminUserDAL.UpdatePassWordByUserID(userID, MD5Hash.GetMd5String(password)) > 0);
 }
Пример #9
0
        public void InsertSupplierInfo(SupplierInfoJsonModel supplierInfo, string userName)
        {
            supplierInfo.PassWord = MD5Hash.GetMd5String(supplierInfo.PassWord);

            supplierInfoDAL.InsertSupplierInfo(supplierInfo, userName);
        }
Пример #10
0
 public static int UpdatePassWordByUserID(int userID, string password)
 {
     return(supplierUserDAL.UpdatePassWordByUserID(userID, MD5Hash.GetMd5String(password)));
 }
Пример #11
0
 public static bool UpdatePassWordByToken(string token, string password)
 {
     return(supplierUserDAL.UpdatePasswordByToken(token, MD5Hash.GetMd5String(password)) > 0);
 }