public LoginController(UserService userapp, LogService logApp, UserLogOnService logonApp, RoleService roleApp) { this.userApp = userapp; this.logApp = logApp; this.logonApp = logonApp; this.roleApp = roleApp; }
public ActionResult Unlock(string username, string password) { var userEntity = UserService.GetByUserName(username); var userLogOnEntity = UserLogOnService.GetByAccount(userEntity.Id); string inputPassword = password.DESEncrypt(userLogOnEntity.SULSecretKey).MD5Encrypt(); if (inputPassword != userLogOnEntity.SULPassword) { return(Warning("密码错误,请重新输入。")); } else { //重新保存用户信息。 Operator operatorModel = new Operator(); operatorModel.UserId = userEntity.Id; operatorModel.Account = userEntity.SUAccount; operatorModel.RealName = userEntity.SURealName; operatorModel.Avatar = userEntity.SUAvatar; operatorModel.CompanyId = userEntity.SUCompanyId; operatorModel.DepartmentId = operatorModel.DepartmentId; operatorModel.LoginTime = DateTime.Now; operatorModel.Token = Guid.NewGuid().ToString().DESEncrypt(); operatorModel.LoginCount = userLogOnEntity.SULLoginCount; operatorModel.MessageCount = 0; OperatorProvider.Instance.Current = operatorModel; } return(Success()); }
public LoginController(UserService userapp, LogService logApp, UserLogOnService logonApp, RoleService roleApp, IConfiguration config) { this.userApp = userapp; this.logApp = logApp; this.logonApp = logonApp; this.roleApp = roleApp; this.config = config; }
public ActionResult Form(Sys_Userlogon model) { if (model.Id == 0) { var primaryKey = UserLogOnService.Insert(model); return(primaryKey > 0 ? Success() : Error()); } else { var row = UserLogOnService.UpdateInfo(model); return(row > 0 ? Success() : Error()); } }
public ActionResult Login(string userName, string password, string verifyCode) { if (userName.IsNullOrEmpty() || password.IsNullOrEmpty() || verifyCode.IsNullOrEmpty()) { return(Error("请求失败,缺少必要参数。")); } if (verifyCode.ToLower() != WebHelper.GetSession(Keys.SESSION_KEY_VCODE)) { return(Warning("验证码错误,请重新输入。")); } var userEntity = UserService.GetByUserName(userName); if (userEntity == null) { return(Warning("该账户不存在,请重新输入。")); } if (userEntity.SUIsEnabled != 1 || userEntity.SUDeleteMark == 1) { return(Warning("该账户已被禁用,请联系管理员。")); } var userLogOnEntity = UserLogOnService.GetByAccount(userEntity.Id); string inputPassword = password.DESEncrypt(userLogOnEntity.SULSecretKey).MD5Encrypt(); if (inputPassword != userLogOnEntity.SULPassword) { LogHelper.Write(Level.Info, "系统登录", "密码错误", userEntity.Id, userEntity.SURealName); return(Warning("密码错误,请重新输入。")); } else { Operator operatorModel = new Operator() { UserId = userEntity.Id, Account = userEntity.SUAccount, RealName = userEntity.SURealName, Avatar = userEntity.SUAvatar, CompanyId = userEntity.SUCompanyId, DepartmentId = userEntity.SUDepartmentId, LoginTime = DateTime.Now, LoginCount = userLogOnEntity.SULLoginCount + 1, MessageCount = 0, Token = Guid.NewGuid().ToString().DESEncrypt(), }; OperatorProvider.Instance.Current = operatorModel; UserLogOnService.UpdateLogin(userLogOnEntity); LogHelper.Write(Level.Info, "系统登录", "登录成功", userEntity.Id, userEntity.SURealName); return(Success()); } }
public ActionResult ModifyPwd(string oldPassword, string newPassword, string confirmPassword) { if (oldPassword.IsNullOrEmpty() || newPassword.IsNullOrEmpty() || confirmPassword.IsNullOrEmpty()) { return(Error("请求失败,缺少必要参数。")); } if (!newPassword.Equals(confirmPassword)) { return(Warning("两次密码输入不一致,请重新确认。")); } int userId = OperatorProvider.Instance.Current.UserId; var userLoginEntity = UserLogOnService.GetByAccount(userId); if (oldPassword.DESEncrypt(userLoginEntity.SULSecretKey).MD5Encrypt() != userLoginEntity.SULPassword) { return(Warning("旧密码验证失败。")); } userLoginEntity.SULPassword = newPassword.DESEncrypt(userLoginEntity.SULSecretKey).MD5Encrypt(); bool isSuccess = UserLogOnService.ModifyPwd(userLoginEntity); return(isSuccess ? Success() : Error()); }
public UserController(UserService userApp, UserLogOnService userLogOnApp) { this.userApp = userApp; this.userLogOnApp = userLogOnApp; }