/// <summary> /// 用户登录 /// </summary> /// <param name="userName"></param> /// <param name="pwd"></param> /// <param name="verifyCode"></param> /// <returns></returns> public static bool Login(LoginVM vm)//string userName, string pwd, string verifyCode) { //EncryptType encryptionStatus = EncryptType.Encryption; string newPassword = string.Empty; //string passwordSalt = string.Empty; //passwordSalt = LoginFacade.GetCustomerPasswordSalt(vm.CustomerID); //vm.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(vm.Password.Replace("+", "%2b")) + passwordSalt); // [2014/12/22 by Swika]增加支持第三方系统导入的账号的密码验证 var encryptMeta = LoginFacade.GetCustomerEncryptMeta(vm.CustomerID); vm.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(vm.Password.Replace("+", "%2b")), encryptMeta); CustomerInfo user = LoginFacade.CustomerLogin(vm.CustomerID, vm.Password); if (user != null) { LoginFacade.UpdateLastLoginTime(user.SysNo); LoginUser lUser = new LoginUser(); lUser.UserDisplayName = user.CustomerName; lUser.UserID = user.CustomerID; lUser.UserSysNo = user.SysNo; lUser.RememberLogin = vm.RememberLogin; lUser.LoginDateText = DateTime.Now.ToString(); lUser.TimeoutText = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString(); WriteUserInfo(lUser); return(true); } return(false); }
public ActionResult AjaxChangePassword(FormCollection form) { string OldPassword = Request["OldPassword"].ToString(); string Password = Request["Password"].ToString(); string RePassword = Request["RePassword"].ToString(); //string salt = LoginFacade.GetCustomerPasswordSalt(CurrUser.UserID); //OldPassword = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(OldPassword.Replace("+", "%2b")) + salt); // [2014/12/22 by Swika]增加支持第三方系统导入的账号的密码验证 var encryptMeta = LoginFacade.GetCustomerEncryptMeta(CurrUser.UserID); OldPassword = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(OldPassword.Replace("+", "%2b")), encryptMeta); if (LoginFacade.CustomerLogin(CurrUser.UserID, OldPassword) == null) { return(Json("旧密码不正确", JsonRequestBehavior.AllowGet)); } else { string encryptPassword = string.Empty; string passwordSalt = string.Empty; PasswordHelper.GetNewPasswordAndSalt(ref Password, ref encryptPassword, ref passwordSalt); //重置密码 if (CustomerFacade.UpdateCustomerPassword(CurrUser.UserID, encryptPassword, passwordSalt)) { return(Json("s", JsonRequestBehavior.AllowGet)); } return(Json("服务器忙,稍后重试", JsonRequestBehavior.AllowGet)); } }
public static CustomerInfoViewModel CustomerLogin(LoginViewModel request) { if (string.IsNullOrEmpty(request.CustomerID)) { throw new BusinessException("登录账号不能为空!"); } else if (string.IsNullOrEmpty(request.Password)) { throw new BusinessException("登录密码不能为空!"); } string newPassword = string.Empty; //string passwordSalt = string.Empty; //passwordSalt = LoginFacade.GetCustomerPasswordSalt(request.CustomerID); //request.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(request.Password.Replace("+", "%2b")) + passwordSalt); // [2014/12/22 by Swika]增加支持第三方系统导入的账号的密码验证 var encryptMeta = LoginFacade.GetCustomerEncryptMeta(request.CustomerID); try { request.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(request.Password.Replace("+", "%2b")), encryptMeta); var loginResult = LoginFacade.CustomerLogin(request.CustomerID, request.Password); if (null != loginResult) { CustomerInfoViewModel user = EntityConverter <CustomerInfo, CustomerInfoViewModel> .Convert(CustomerFacade.GetCustomerInfo(loginResult.SysNo), (s, t) => { t.RegisterTimeString = s.RegisterTime.ToString("yyyy年MM月dd日 HH:mm:ss"); t.AvtarImage = s.ExtendInfo.AvtarImage; t.AvtarImageDBStatus = s.ExtendInfo.AvtarImageDBStatus; }); if (user != null) { LoginFacade.UpdateLastLoginTime(user.SysNo); LoginUser lUser = new LoginUser(); lUser.UserDisplayName = user.CustomerName; lUser.UserID = user.CustomerID; lUser.UserSysNo = user.SysNo; lUser.RememberLogin = true; lUser.LoginDateText = DateTime.Now.ToString(); lUser.TimeoutText = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString(); CookieHelper.SaveCookie <LoginUser>("LoginCookie", lUser); } System.Threading.Thread.Sleep(1000); return(user); } else { throw new BusinessException("登录失败,用户名或者密码错误!"); } } catch { throw new BusinessException("登录失败,用户名或者密码错误!"); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="userName"></param> /// <param name="pwd"></param> /// <param name="verifyCode"></param> /// <returns></returns> public static bool Login(LoginVM vm)//string userName, string pwd, string verifyCode) { //EncryptType encryptionStatus = EncryptType.Encryption; string newPassword = string.Empty; //string passwordSalt = string.Empty; //passwordSalt = LoginFacade.GetCustomerPasswordSalt(vm.CustomerID); //vm.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(vm.Password.Replace("+", "%2b")) + passwordSalt); // [2014/12/22 by Swika]增加支持第三方系统导入的账号的密码验证 CustomerInfo user = null; //if (vm.SourceType == CustomerSourceType.TLYH) //{ // user = LoginFacade.TLYHCustomerLogin(vm.CustomerID, vm.Password); // CookieHelper.SaveCookie<int>("BankAccountPoint", user.BankAccountPoint);//存储网银用户积分到cookie //} //else //{ var encryptMeta = LoginFacade.GetCustomerEncryptMeta(vm.CustomerID); if (encryptMeta == null) { return(false); } vm.Password = PasswordHelper.GetEncryptedPassword(HttpUtility.UrlDecode(vm.Password.Replace("+", "%2b")), encryptMeta); user = LoginFacade.CustomerLogin(vm.CustomerID, vm.Password); //} if (user != null) { LoginFacade.UpdateLastLoginTime(user.SysNo); LoginUser lUser = new LoginUser(); lUser.UserDisplayName = user.CustomerName; lUser.UserID = user.CustomerID; lUser.UserSysNo = user.SysNo; lUser.CustomerRank = user.CustomerRank; lUser.RememberLogin = vm.RememberLogin; lUser.LoginDateText = DateTime.Now.ToString(); lUser.TimeoutText = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString(); WriteUserInfo(lUser); LoginFacade.ClearCustomerLoginFailedCount(vm.CustomerID); return(true); } LoginFacade.IncrementCustomerLoginFailedCount(vm.CustomerID); return(false); }