/// <summary> /// 验证用户名密码 /// </summary> /// <param name="username">用户名</param> /// <param name="password">md5(16位)加密后的秘密</param> /// <returns></returns> public async Task <UserEntity> CheckLogin(string username, string password, string tenantId) { //获取用户对象 UserEntity userEntity = await service.FindEntityASync(t => t.Account == username && t.TenantId == tenantId); if (userEntity == null) { throw new Exception("账户不存在,请重新输入"); } if (userEntity.EnabledMark == false) { throw new Exception("账户被系统锁定,请联系管理员"); } //获取用户登录对象 UserLogOnEntity userLogOnEntity = await userLogOnApp.GetForm(userEntity.Id, tenantId); //密码0000 MD5加密后 de54ef2d07c608096fddb77a27c5f126 //验证密码 string pwd = Encryptor.EncryptPWD(password, userLogOnEntity.UserSecretkey); if (pwd != userLogOnEntity.UserPassword) { return(null); } //记录登录日志 await WriteLoginLog(userLogOnEntity); return(userEntity); }
public void ChangePwd(string username, string oldpassword, string newpassword) { UserEntity userEntity = service.FindEntity(t => t.F_Account == username); if (userEntity != null) { if (userEntity.F_EnabledMark == true) { UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id); string dbPassword = Md5.md5(DESEncrypt.Encrypt(oldpassword.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); if (dbPassword == userLogOnEntity.F_UserPassword) { userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(newpassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); userLogOnApp.UpdateForm(userLogOnEntity); } else { throw new Exception("原密码不正确,请重新输入"); } } else { throw new Exception("账户被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }
public ActionResult SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { string[] arrF_Area = Request.Form.GetValues("F_Area[]"); userEntity.F_Area = string.Join(",", arrF_Area); userApp.SubmitForm(userEntity, userLogOnEntity, keyValue); return(Success("操作成功。")); }
public ActionResult SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { //组织机构编号 string organizationCode = null; if (userEntity.F_IsHisAccount == null) { userEntity.F_IsHisAccount = false; } //是否机构账户 if (userEntity.F_IsHisAccount == true) { var inputParam = new UserInfoParam() { UserName = userEntity.F_Account, Pwd = userLogOnEntity.F_UserPassword, ManufacturerNumber = userEntity.F_ManufacturerNumber, }; string inputParamJson = JsonConvert.SerializeObject(inputParam, Formatting.Indented); var verificationCode = _basicService.GetVerificationCode("01", inputParamJson); //获取userid if (verificationCode == null) { throw new Exception("基层用户登陆失败!!!"); } userEntity.F_HisUserId = verificationCode.UserId; organizationCode = verificationCode.OrganizationCode; } userApp.SubmitForm(userEntity, userLogOnEntity, keyValue); //是否机构账户 if (userEntity.F_IsHisAccount == true) { //更新机构编号 organizeApp.UpDateEnCode(userEntity.F_DepartmentId, organizationCode); } return(Success("操作成功。")); }
/// <summary> /// 登录密码登录 /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public UserEntity Login(string username, string password) { UserEntity userEntity = service.FindEntity(t => t.F_Account == username); if (userEntity == null) { throw new Exception("账户不存在,请重新输入"); } if (userEntity.F_EnabledMark != true) { throw new Exception("账户被系统锁定,请联系管理员"); } UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id); string dbPassword = Md5Encrypt.Md5(AES.Encrypt(password.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); if (dbPassword != userLogOnEntity.F_UserPassword) { throw new Exception("密码不正确,请重新输入"); } DateTime lastVisitTime = DateTime.Now; int LogOnCount = userLogOnEntity.F_LogOnCount ?? +1; if (userLogOnEntity.F_LastVisitTime != null) { userLogOnEntity.F_PreviousVisitTime = userLogOnEntity.F_LastVisitTime; } userLogOnEntity.F_LastVisitTime = lastVisitTime; userLogOnEntity.F_LogOnCount = LogOnCount; userLogOnApp.UpdateForm(userLogOnEntity); return(userEntity); }
public UserEntity CheckLogin(string username, string password) { UserEntity userEntity = service.FindEntity(t => t.F_Account == username); if (userEntity != null) { if (userEntity.F_EnabledMark == true) { UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id); //string dbPassword = Md5.md5(DESEncrypt.Encrypt(password.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); //if (dbPassword == userLogOnEntity.F_UserPassword) { DateTime lastVisitTime = DateTime.Now; int LogOnCount = (userLogOnEntity.F_LogOnCount).ToInt() + 1; if (userLogOnEntity.F_LastVisitTime != null) { userLogOnEntity.F_PreviousVisitTime = userLogOnEntity.F_LastVisitTime.ToDate(); } userLogOnEntity.F_LastVisitTime = lastVisitTime; userLogOnEntity.F_LogOnCount = LogOnCount; userLogOnApp.UpdateForm(userLogOnEntity); return(userEntity); } } else { throw new Exception("账户被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }
/// <summary> /// 操作用户信息 /// </summary> /// <param name="userEntity"></param> /// <param name="userLogOnEntity"></param> /// <param name="keyValue"></param> public void SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { ResultClass <int> _ret = new ResultClass <int>(); using (var db = new RepositoryBase().BeginTrans()) { if (!string.IsNullOrEmpty(keyValue)) { db.Update(userEntity); } else { userLogOnEntity.F_Id = userEntity.F_Id; userLogOnEntity.F_UserId = userEntity.F_Id; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.F_UserPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); db.Insert(userEntity); db.Insert(userLogOnEntity); } _ret = db.Commit(); } if (!_ret.Result) { throw new System.Exception(_ret.ErrorMessage); } }
public async Task <UserEntity> Login(string username, string password) { return(await Task.Run(() => { UserEntity userEntity = userService.FindEntity(t => t.Account == username); if (userEntity == null) { throw new Exception("账户不存在,请重新输入"); } if (userEntity.EnabledMark != true) { throw new Exception("账户被系统锁定,请联系管理员"); } UserLogOnEntity userLogOnEntity = userLogService.FindEntity(o => o.UserId == userEntity.Id); string dbPassword = Md5Encrypt.Md5(AES.Encrypt(password.ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower(); if (dbPassword != userLogOnEntity.UserPassword) { throw new Exception("密码不正确,请重新输入"); } DateTime lastVisitTime = DateTime.Now; int LogOnCount = userLogOnEntity.LogOnCount ?? +1; if (userLogOnEntity.LastVisitTime != null) { userLogOnEntity.PreviousVisitTime = userLogOnEntity.LastVisitTime; } userLogOnEntity.LastVisitTime = lastVisitTime; userLogOnEntity.LogOnCount = LogOnCount; userLogService.Update(userLogOnEntity); return userEntity; })); }
public void SubmitForm(OrderEntity orderEntity, UserLogOnEntity userLogOnEntity, string keyValue) { using (var db = base.Connection) { db.Open(); var tran = db.BeginTransaction(); try { if (!string.IsNullOrEmpty(keyValue)) { var sql = base.GetSqlLam().Update(orderEntity).Where(m => m.F_Id == keyValue); db.Execute(sql.SqlString, sql.Parameters, tran); } else { var sql = base.GetSqlLam().Insert(orderEntity); db.Execute(sql.SqlString, sql.Parameters, tran); } tran.Commit(); } catch (Exception ex) { tran.Rollback(); } } }
public UserEntity InitLogin(string username) { UserEntity userEntity = service.FindEntity(t => t.F_Account == username); if (userEntity != null) { if (userEntity.F_EnabledMark == true) { UserLogOnEntity userLogOnEntity = userLogOnApp.GetForm(userEntity.F_Id); DateTime lastVisitTime = DateTime.Now; int LogOnCount = (userLogOnEntity.F_LogOnCount).ToInt() + 1; if (userLogOnEntity.F_LastVisitTime != null) { userLogOnEntity.F_PreviousVisitTime = userLogOnEntity.F_LastVisitTime.ToDate(); } userLogOnEntity.F_LastVisitTime = lastVisitTime; userLogOnEntity.F_LogOnCount = LogOnCount; userLogOnApp.UpdateForm(userLogOnEntity); return(userEntity); } else { throw new Exception("账户被系统锁定,请联系管理员"); } } else { throw new Exception("账户不存在,请重新输入"); } }
public ApiResultModel Login(UserLogOnEntity userLogOnEntity) { //检测cookie是否创建 HttpContext context = HttpContext.Current; HttpCookie cookie = context.Request.Cookies.Get("_user"); if (null == cookie) { //执行登录操作 //如果登录成功写入Cookie cookie = new HttpCookie("_user"); cookie.Value = userLogOnEntity.C_UserId.ToString(); cookie.Expires.AddMinutes(5); context.Response.SetCookie(cookie); } else { string value = cookie.Value; cookie.Expires.AddMinutes(5); } var result = new ApiResultModel() { IsSuccess = false, StatusCode = StatusEnum.StatusCodeEnum.Error, Message = StringResource.LoginFail }; result.IsSuccess = false; return(result); }
public void SubmitForm(MyProjProgEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { using (var db = new RepositoryBase().BeginTrans()) { if (!string.IsNullOrEmpty(keyValue)) { db.Update(userEntity); } else { userEntity.Create(); userEntity.FBillNO = userEntity.FID; string tmpstrWeek = GetWeeks(userEntity.FStarDate, userEntity.FEndDate); userEntity.FWeek = int.Parse(tmpstrWeek == ""?"0":tmpstrWeek); userEntity.FLastBill = GetLastBill(userEntity.FStarDate, userEntity.FEndDate, userEntity.FCode); userLogOnEntity.F_Id = userEntity.FID.ToString(); userLogOnEntity.F_UserId = userEntity.FWritePeople; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); //userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.F_UserPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); db.Insert(userEntity); db.Insert(userLogOnEntity); } db.Commit(); } }
public void SubmitForm(MyNeedCheckProjEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { using (var db = new RepositoryBase().BeginTrans()) { if (string.IsNullOrWhiteSpace(userEntity.FFinshInfo) == true) { userEntity.FFinshInfo = ""; } if (!string.IsNullOrEmpty(keyValue)) { userEntity.FID = keyValue; db.Update(userEntity); } else { userEntity.Create(); //userEntity.FBillNO = userEntity.FID; string tmpstrWeek = myCommService.GetWeeks(userEntity.FStarDate, userEntity.FEndDate); userEntity.FWeek = int.Parse(tmpstrWeek == "" ? "0" : tmpstrWeek); userLogOnEntity.F_Id = userEntity.FID.ToString(); userLogOnEntity.F_UserId = userEntity.FWritePeople; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); //userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.F_UserPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); db.Insert(userEntity); db.Insert(userLogOnEntity); } db.Commit(); } }
public void SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { using (var db = base.Connection) { var tran = db.BeginTransaction(); try { if (!string.IsNullOrEmpty(keyValue)) { var sql = base.GetSqlLam().Update(userEntity).Where(m => m.F_Id == keyValue); db.Execute(sql.SqlString, sql.Parameters, tran); } else { userLogOnEntity.F_Id = userEntity.F_Id; userLogOnEntity.F_UserId = userEntity.F_Id; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.F_UserPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); var sql = base.GetSqlLam().Insert(userEntity); db.Execute(sql.SqlString, sql.Parameters, tran); var query = new SqlLam <UserLogOnEntity>().Insert(userLogOnEntity); db.Execute(query.SqlString, query.Parameters, tran); } tran.Commit(); } catch { tran.Rollback(); } } }
public async Task <ActionResult> SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { if (string.IsNullOrEmpty(keyValue)) { userEntity.F_IsAdmin = false; userEntity.F_DeleteMark = false; userEntity.F_IsBoss = false; userEntity.F_OrganizeId = _service.currentuser.CompanyId; } else { if (_service.currentuser.UserId == keyValue) { return(Error("操作失败,不能修改用户自身")); } } try { await _service.SubmitForm(userEntity, userLogOnEntity, keyValue); return(await Success("操作成功。", "", keyValue)); } catch (Exception ex) { return(await Error(ex.Message, "", keyValue)); } }
public void SubmitForm(AgentEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { using (var db = new RepositoryBase().BeginTrans()) { if (userEntity.c_agnet_type == null) { userEntity.c_agnet_type = 1; } if (userEntity.c_state == null) { userEntity.c_state = 1; } if (userEntity.c_had_reward == null) { userEntity.c_had_reward = true; } if (!string.IsNullOrEmpty(keyValue)) { db.Update(userEntity); } else { userLogOnEntity.F_Id = userEntity.F_Id; userLogOnEntity.F_UserId = userEntity.F_Id; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.F_UserPassword = userEntity.c_login_pwd; userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.F_UserPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); db.Insert(userEntity); db.Insert(userLogOnEntity); } db.Commit(); } }
public void InsertForm(UserLogOnEntity userLogOnEntity, string userIds) { userLogOnEntity.Id = userIds; userLogOnEntity.UserId = userIds; userLogOnEntity.UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userLogOnEntity.UserPassword, 32).ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower(); service.Insert(userLogOnEntity); }
public void LoginTest() { UserLogOnEntity entity = new UserLogOnEntity { C_UserPassword = Guid.NewGuid().ToString(), C_UserSecretkey = Guid.NewGuid().ToString() }; }
public Task <int> RevisePassword(string userPassword, string keyValue) { UserLogOnEntity userLogOnEntity = new UserLogOnEntity(); userLogOnEntity.Id = keyValue; userLogOnEntity.UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.UserPassword = Md5.md5(AESEncrypt.Encrypt(userPassword.ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower(); return(service.UpdateAsync(userLogOnEntity)); }
public void ChangeUserPassword(UserLogOnEntity userLogOnEntity, string password) { using (var db = this.repositoryBase) { userLogOnEntity.F_UserPassword = EncryptProvider.Md5(password, Code.Internal.MD5Length.L32).ToLower(); userLogOnEntity.F_ChangePasswordDate = DateTime.Now; db.Update <UserLogOnEntity>(userLogOnEntity); } }
public void ChangeUserPassword(UserLogOnEntity userLogOnEntity, string password) { using (var db = new RepositoryBase()) { userLogOnEntity.F_UserPassword = Md5.md5(password, 32).ToLower(); userLogOnEntity.F_ChangePasswordDate = DateTime.Now; db.Update <UserLogOnEntity>(userLogOnEntity); } }
public void RevisePassword(string userPassword, string keyValue) { UserLogOnEntity userLogOnEntity = new UserLogOnEntity(); userLogOnEntity.F_Id = keyValue; userLogOnEntity.F_UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.F_UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userPassword, 32).ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), 32).ToLower(); service.Update(userLogOnEntity); }
void WWUserControllerTests() { uc = null; loginEntity = null; model = null; Debug.WriteLine("测试结束,销毁UserController,uc=" + uc); Debug.WriteLine("测试结束,销毁UserLogOnEntity,loginEntity=" + loginEntity); Debug.WriteLine("测试结束,ApiResultModelBase,model=" + model); }
public void RevisePassword(string userPassword, string keyValue) { UserLogOnEntity userLogOnEntity = new UserLogOnEntity(); userLogOnEntity.F_Id = keyValue; userLogOnEntity.F_UserSecretkey = EncryptProvider.CreateDesKey(); userLogOnEntity.F_UserPassword = EncryptProvider.Md5(EncryptProvider.DESEncrypt(userPassword.ToLower(), userLogOnEntity.F_UserSecretkey).ToLower(), Code.Internal.MD5Length.L32).ToLower(); service.Update(userLogOnEntity); }
public void RevisePassword(string userPassword, string keyValue) { UserLogOnEntity userLogOnEntity = new UserLogOnEntity(); userLogOnEntity.Id = keyValue; userLogOnEntity.UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower(); userLogOnEntity.UserPassword = Md5.md5(DESEncrypt.Encrypt(Md5.md5(userPassword, 32).ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower(); service.Update(userLogOnEntity); //添加日志 LogHelp.logHelp.WriteDbLog(true, "重置用户密码=>" + userLogOnEntity.UserId, Enums.DbLogType.Update, "用户管理"); }
public void SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { userEntity.Modify(keyValue); } else { userEntity.Create(); } service.SubmitForm(userEntity, userLogOnEntity, keyValue); }
public ActionResult SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue) { try { userApp.SubmitForm(userEntity, userLogOnEntity, keyValue); return(Success("操作成功。")); } catch (Exception ex) { return(Error(ex.Message)); } }
public UserEntity CheckLogin(string username, string password) { UserEntity userEntity = service.FindEntity(user => user.C_Account == username); if (null != userEntity) { if (userEntity.C_EnabledMark == true) { UserLogOnEntity userLogOnEntity = userLogOnApp } } }
public ActionResult SubmitForm(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string keyValue, string roleId) { try { userApp.SubmitForm(userEntity, userLogOnEntity, keyValue, roleId); return(Success("操作成功。")); } catch (System.Exception e) { return(Error(e.Message)); } }
/// <summary> /// 保存用户对象 /// </summary> /// <param name="userEntity">用户实体</param> /// <param name="userLogOnEntity">登录实体</param> /// <param name="id">用户Id,为空则创建实体,否则更新实体</param> public Task <int> Save(UserEntity userEntity, UserLogOnEntity userLogOnEntity, string id, string userId) { if (!string.IsNullOrEmpty(id)) { userEntity.AttachModifyInfo(id, userId); } else { userEntity.AttachCreateInfo(userId); } return(service.Save(userEntity, userLogOnEntity, id, userId)); }