public JsonResult Login(string UserName, string Password, string Code) { if (Session["Code"] == null) { return(Json(JsonHandler.CreateMessage(0, "请重新刷新验证码"), JsonRequestBehavior.AllowGet)); } if (Session["Code"].ToString().ToLower() != Code.ToLower()) { return(Json(JsonHandler.CreateMessage(0, "验证码错误"), JsonRequestBehavior.AllowGet)); } SysUser user = AccountBLL.Login(UserName, ValueConvert.MD5(Password)); if (user == null) { return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"), JsonRequestBehavior.AllowGet)); } else if (!Convert.ToBoolean(user.State))//被禁用了 { return(Json(JsonHandler.CreateMessage(0, "账户被系统禁用"), JsonRequestBehavior.AllowGet)); } AccountModel account = new AccountModel(); account.Id = user.Id; account.TrueName = user.TrueName; Session["Account"] = account; return(Json(JsonHandler.CreateMessage(1, ""), JsonRequestBehavior.AllowGet)); }
public JsonResult Create(SysUserModel model) { if (model != null && ModelState.IsValid) { Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession; string curUserId = OpeCur.AccountNow.Id; model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; model.Password = ValueConvert.MD5(model.Password); model.CreatePerson = OpeCur.AccountNow.TrueName; model.State = true; serviceSession.SysUser.Create(ref errors, model); if (serviceSession.SaveChange() > 0) { LogHandler.WriteServiceLog(curUserId, "Id:" + model.Id + ",Name:" + model.UserName, "成功", "创建", "用户设置"); return(OpeCur.AjaxMsgOK("创建成功!")); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(curUserId, "Id:" + model.Id + ",Name:" + model.UserName + "," + ErrorCol, "失败", "创建", "用户设置"); return(OpeCur.AjaxMsgNOOK("创建失败!" + ErrorCol)); } } else { return(OpeCur.AjaxMsgNOOK(Resource.ModelStateValidFail)); } }
public JsonResult EditPwd(string oldPwd, string newPwd) { SysUser user = accountBLL.Login(GetUserId(), ValueConvert.MD5(oldPwd)); if (user == null) { return(Json(JsonHandler.CreateMessage(0, "旧密码不匹配!"), JsonRequestBehavior.AllowGet)); } SysUserEditModel editModel = new SysUserEditModel(); editModel.Id = GetUserId(); editModel.Password = ValueConvert.MD5(newPwd); if (userBLL.EditPwd(ref errors, editModel)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + GetUserId() + ",密码:********", "成功", "初始化密码", "用户设置"); return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + GetUserId() + ",,密码:********" + ErrorCol, "失败", "初始化密码", "用户设置"); return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ":" + ErrorCol), JsonRequestBehavior.AllowGet)); } }
public JsonResult Create(SysUserModel model) { if (model != null && ModelState.IsValid) { model.Id = ResultHelper.NewId; model.CreateTime = ResultHelper.NowTime; model.Password = ValueConvert.MD5(model.Password); model.CreatePerson = GetUserTrueName(); model.State = true; if (m_BLL.Create(ref errors, model)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Name:" + model.UserName, "成功", "创建", "用户设置"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Name:" + model.UserName + "," + ErrorCol, "失败", "创建", "用户设置"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet)); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail), JsonRequestBehavior.AllowGet)); } }
public ActionResult Index(string url) { //Convert.ToInt16("dddd"); //系统名称 ViewBag.WebName = siteConfig.webname; //公司名称 ViewBag.ComName = siteConfig.webcompany; // ViewBag.CopyRight = siteConfig.webcopyright; #if DEBUG SysUser user = accountBLL.Login("admin", ValueConvert.MD5("zxczxc")); AccountModel account = new AccountModel(); account.Id = user.Id; account.TrueName = user.TrueName; account.Photo = string.IsNullOrEmpty(user.Photo) ? "/Images/Photo.jpg" : user.Photo; Session["Account"] = account; GetThemes(user.Id); //在线用户统计 //OnlineHttpModule.ProcessRequest(); return(RedirectToAction("Index", "Home")); #else return(View()); #endif }
public JsonResult Login(string UserName, string Password, string Code) { if (Session["Code"] == null) { return(Json(JsonHandler.CreateMessage(0, "请重新刷新验证码"), JsonRequestBehavior.AllowGet)); } if (Session["Code"].ToString().ToLower() != Code.ToLower()) { return(Json(JsonHandler.CreateMessage(0, "验证码错误"), JsonRequestBehavior.AllowGet)); } SysUser user = accountBLL.Login(UserName, ValueConvert.MD5(Password)); if (user == null) { LogHandler.WriteServiceLog(UserName, ResultHelper.NowTime + "登录系统,IP:" + ResultHelper.GetUserIP() + "账户或密码错误", "失败", "登录", "系统入口"); return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"), JsonRequestBehavior.AllowGet)); } else if (!Convert.ToBoolean(user.State))//被禁用 { return(Json(JsonHandler.CreateMessage(0, "账户被系统禁用"), JsonRequestBehavior.AllowGet)); } AccountModel account = new AccountModel(); account.Id = user.Id; account.TrueName = user.TrueName; account.Photo = string.IsNullOrEmpty(user.Photo)?"/Images/Photo.jpg":user.Photo; Session["Account"] = account; GetThemes(user.Id); //在线用户统计 //OnlineHttpModule.ProcessRequest(); LogHandler.WriteServiceLog(UserName, ResultHelper.NowTime + "登录系统,IP:" + ResultHelper.GetUserIP(), "成功", "登录", "系统入口"); return(Json(JsonHandler.CreateMessage(1, ""), JsonRequestBehavior.AllowGet)); }
public void EditPwd(ref ValidationErrors errors, string id, string pwd) { SysUser entity = m_Rep.GetById(id); if (entity == null) { errors.Add(Resource.Disable); } entity.Password = ValueConvert.MD5(pwd); }
//[SupportFilter] public JsonResult Create(SysUser model) { if (model != null) { model.CreateTime = ResultHelper.NowTime.ToString("yyyy-MM-dd"); model.Password = ValueConvert.MD5(model.Password); model.CreatePerson = GetUserTrueName(); if (!string.IsNullOrEmpty(model.DepId)) { model.DepName = structBLL.m_Rep.Find(Convert.ToInt32(model.DepId)).Name; } if (!string.IsNullOrEmpty(model.PosId)) { model.PosName = positionBLL.m_Rep.Find(Convert.ToInt32(model.PosId)).Name; } if (!string.IsNullOrEmpty(model.Province) && !"--未选择--".Equals(model.Province)) { model.ProvinceName = areasBLL._SysAreasRepository.Find(a => a.KEY_Id == model.Province).Name; } if (!string.IsNullOrEmpty(model.City) && !"--未选择--".Equals(model.City)) { model.CityName = areasBLL._SysAreasRepository.Find(a => a.KEY_Id == model.City).Name; } if (!string.IsNullOrEmpty(model.Village) && !"--未选择--".Equals(model.Village)) { model.VillageName = areasBLL._SysAreasRepository.Find(a => a.KEY_Id == model.Village).Name; } model.State = "true"; if (m_BLL.m_Rep.Create(model)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Name:" + model.UserName, "成功", "创建", "用户设置"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + model.Id + ",Name:" + model.UserName + "," + ErrorCol, "失败", "创建", "用户设置"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet)); } } else { return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail), JsonRequestBehavior.AllowGet)); } }
public JsonResult Login(string UserName, string Password, string Code, SysUserMaintenanceDTO sysUserMaintenanceDTO) { if (Session["Code"] == null) { return(Json(JsonHandler.CreateMessage(0, "请重新刷新验证码"), JsonRequestBehavior.AllowGet)); } if (Session["Code"].ToString().ToLower() != Code.ToLower()) { return(Json(JsonHandler.CreateMessage(0, "验证码错误"), JsonRequestBehavior.AllowGet)); } TransactionalInformation transaction; //AccountViewModel accountViewModel = new AccountViewModel(); AccountApplicationService accountApplicationService = new AccountApplicationService(accountDataService); SysUser user = accountApplicationService.Login(UserName, ValueConvert.MD5(Password), out transaction); //accountViewModel.SysUser = user; //accountViewModel.ReturnStatus = transaction.ReturnStatus; //accountViewModel.ReturnMessage = transaction.ReturnMessage; //if (accountViewModel.ReturnStatus == true) //{ // //return Json(JsonHandler.CreateMessage(0, accountViewModel.ReturnStatus.ToString()), JsonRequestBehavior.AllowGet); // return Json(JsonHandler.CreateMessage(0, user.State.ToString()), JsonRequestBehavior.AllowGet); //} if (user == null) { return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"), JsonRequestBehavior.AllowGet)); } else if (!Convert.ToBoolean(user.State))//被禁用 { return(Json(JsonHandler.CreateMessage(0, "账户被系统禁用"), JsonRequestBehavior.AllowGet)); } Account account = new Account(); account.Id = user.Id; account.TrueName = user.TrueName; Session["Account"] = account; return(Json(JsonHandler.CreateMessage(1, ""), JsonRequestBehavior.AllowGet)); }
//[SupportFilter(ActionName = "Edit")] public JsonResult ReSet(string Id, string Pwd) { SysUser editModel = m_BLL.m_Rep.Find(Convert.ToInt32(Id)); editModel.Password = ValueConvert.MD5(Pwd); if (m_BLL.m_Rep.Update(editModel)) { LogHandler.WriteServiceLog(GetUserId(), "Id:" + Id + ",密码:********", "成功", "初始化密码", "用户设置"); return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed), JsonRequestBehavior.AllowGet)); } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id:" + Id + ",,密码:********" + ErrorCol, "失败", "初始化密码", "用户设置"); return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ":" + ErrorCol), JsonRequestBehavior.AllowGet)); } }
public object Login(string userName, string password) { SysUser user = accountBLL.Login(userName, ValueConvert.MD5(password)); if (user == null) { return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"))); } else if (!Convert.ToBoolean(user.State))//被禁用 { return(Json(JsonHandler.CreateMessage(0, "账户被系统禁用"))); } FormsAuthenticationTicket token = new FormsAuthenticationTicket(0, userName, DateTime.Now, DateTime.Now.AddHours(1), true, string.Format("{0}&{1}", userName, password), FormsAuthentication.FormsCookiePath); //返回登录结果、用户信息、用户验证票据信息 var Token = FormsAuthentication.Encrypt(token); //将身份信息保存在session中,验证当前请求是否是有效请求 HttpContext.Current.Session[userName] = Token; return(Json(JsonHandler.CreateMessage(1, Token))); }
public async Task <Response> RegisterUser(SysUser model) { Response res = new Response(); try { var data = await context.SysUser.Where(m => m.UserMobile == model.UserMobile && m.IsDel == 0).FirstOrDefaultAsync(); if (data != null) { res.Code = 3; res.Message = "该手机号码已经被注册"; return(res); } var data1 = await context.SysUser.Where(m => m.UserAccount == model.UserAccount && m.IsDel == 0).FirstOrDefaultAsync(); if (data1 != null) { res.Code = 3; res.Message = "该用户已存在"; return(res); } model.CreateTime = DateTime.Now; model.UserPassword = ValueConvert.MD5(model.UserPassword); await context.SysUser.AddAsync(model); await context.SaveChangesAsync(); } catch (Exception e) { res.Code = 2; res.Message = e.Message; } return(res); }
public JsonResult Login(string userName, string password, string Code) { //验证验证码 if (Session["Code"] == null) { return(Json(JsonHandler.CreateMessage(0, "请重新刷新验证码"), JsonRequestBehavior.AllowGet)); } if (Session["Code"].ToString().ToLower() != Code.ToLower()) { return(Json(JsonHandler.CreateMessage(0, "验证码错误"), JsonRequestBehavior.AllowGet)); } //验证用户 SysUser user = accoutBLL.Login(userName, ValueConvert.MD5(password)); if (user == null) { return(Json(JsonHandler.CreateMessage(0, "用户名或密码错误"), JsonRequestBehavior.AllowGet)); } else if (!Convert.ToBoolean(user.State))//被禁用 { return(Json(JsonHandler.CreateMessage(0, "用户被系统禁用"), JsonRequestBehavior.AllowGet)); } AccountModel account = new AccountModel(); account.Id = user.Id; account.TrueName = user.TrueName; Session["Account"] = account; //在线用户统计 //OnlineHttpModule.ProcessRequest(); return(Json(JsonHandler.CreateMessage(1, ""), JsonRequestBehavior.AllowGet)); }
public JsonResult ReSet(string Id, string pwd) { Apps.IService.IServiceSession serviceSession = OpeCur.ServiceSession; if (ValueConvert.MD5(pwd) == OpeCur.AccountNow.Password) { return(OpeCur.AjaxMsgNOOK(Resource.EditFail + "密码不能和当前密码相同")); } serviceSession.SysUser.EditPwd(ref errors, Id, pwd); string ErrorCol = errors.Error; if (serviceSession.SaveChange() > 0) { LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",密码:********", "成功", "初始化密码", "用户设置"); //Session.Abandon(); //Session.Clear(); return(OpeCur.AjaxMsgOK(Resource.EditSucceed + ErrorCol)); } else { LogHandler.WriteServiceLog(OpeCur.AccountNow.Id, "Id:" + Id + ",,密码:********" + ErrorCol, "失败", "初始化密码", "用户设置"); return(OpeCur.AjaxMsgNOOK(Resource.EditFail + ErrorCol)); } }
public SysUser ResponseToken(LoginRequestDTO model) { var data = context.SysUser.Where(m => m.UserAccount == model.Account && m.UserPassword == ValueConvert.MD5(model.Password)).FirstOrDefault(); if (data == null) { return(null); } else { return(data); } }
public async Task <Response> UserLogin(string account, string password) { Response res = new Response(); try { var data = await context.SysUser.Where(m => m.UserAccount == account && m.UserPassword == ValueConvert.MD5(password)).FirstOrDefaultAsync(); if (data == null) { res.Code = 3; res.Message = "登陆失败"; return(res); } } catch (Exception e) { res.Code = 2; res.Message = e.Message; } return(res); }
public JsonResult Login(Apps.Models.ViewModel.LoginModel usrLoginModel) { string userAgent = HttpContext.Request.UserAgent.ToLower();//compatible if ((userAgent.Contains("mozilla/4.0") || userAgent.Contains("compatible") || userAgent.Contains("msie 7.0") || userAgent.Contains("msie 6.0") || userAgent.Contains("msie 8.0") || userAgent.Contains("msie 9.0"))) { return(OpeCur.AjaxMsgNOOK(Resource.BrowserCompatibility)); } if (ModelState.IsValid) { if (Session["VCode"] != null && usrLoginModel.LoginCode.IsSame(Session["VCode"].ToString())) { string loginName = usrLoginModel.LoginName; AccountModel account = OpeCur.ServiceSession.SysUser.GetAccountByUserName(loginName); if (account == null) { return(OpeCur.AjaxMsgNOOK("用户名错误!")); } else if (!Convert.ToBoolean(account.State))//被禁用 { return(OpeCur.AjaxMsgNOOK("账户被禁用!")); } else { if (account.Password.IsSame(ValueConvert.MD5(usrLoginModel.Password))) { //AccountModel account = new AccountModel(); //account.Id = usr.Id; //account.UserName = usr.UserName; //account.TrueName = usr.TrueName; //account.Photo = string.IsNullOrEmpty(usr.Photo) ? "/Images/Photo.jpg" : usr.Photo; //OpeCur.AccountNow = account; //Session["uinfo"] = account; GetThemes(account.Id); OpeCur.AccountNow = account; OpeCur.UsrHasMerchantCode = account.HasMerchantCode; OpeCur.UsrNowPers = OpeCur.ServiceSession.SysUser.GetUserPermission(account.Id); OpeCur.SetRedisSession(); LogHandler.WriteServiceLog(account.UserName, ResultHelper.NowTime + "登录系统,IP:" + ResultHelper.GetUserIP(), "成功", "登录", "系统入口"); OpeCur.ServiceSession.SaveChange(); return(OpeCur.AjaxMsgOK("登录成功了!", "/Home/index")); } //d.2 登录失败 else { return(OpeCur.AjaxMsgNOOK("登录密码错误!")); } } } else { return(OpeCur.AjaxMsgNOOK("验证码输入错误!")); } } else { return(OpeCur.AjaxMsgNOOK(Resource.ModelStateValidFail)); } }