public IHttpActionResult UserPassRecovery(dynamic obj) { JObject je = new JObject(); JObject jo = new JObject(); string getStr = string.Empty; je = (JObject)JsonConvert.DeserializeObject(obj.ToString()); SqlSugarClient sql = datahandle.GetDataConnect(); //校验客户账户是否存在 List <user_login> list_user = sql.Queryable <user_login>().Where(t => t.userName == je["userName"].ToString()).ToList(); if (list_user.Count > 0) { user_login user_LoginModel = list_user.First(); user_LoginModel.userPwd = Md5Control.MD5Encrypt(je["userPwd"].ToString()); int Result = sql.Updateable <user_login>(user_LoginModel).ExecuteCommand(); if (Result == 1) { jo.Add("Message", "修改完成"); jo.Add("Result", 1); } else { jo.Add("Result", 0); jo.Add("Message", "修改失败"); } } return(Json(jo.ToString())); }
public IHttpActionResult PwdUpdate(dynamic obj) { JObject je = new JObject(); JObject jo = new JObject(); try { je = (JObject)JsonConvert.DeserializeObject(obj.ToString()); LoggerHelp.LogInfo("PwdUpdate接收数据:" + je); SqlSugarClient sql = datahandle.GetDataConnect(); List <user_login> user_Logins = sql.Queryable <user_login>().Where(t => t.userName == je["userName"].ToString()).ToList(); if (user_Logins.Count == 1) { user_login user_Login = user_Logins[0]; if (user_Login.userPwd == Md5Control.MD5Encrypt(je["userPwdOld"].ToString())) { user_Login.userPwd = Md5Control.MD5Encrypt(je["userPwdNew"].ToString()); int Result = sql.Updateable(user_Login).ExecuteCommand(); if (Result == 1) { jo.Add("Result", 1); jo.Add("Message", "密码更换成功"); } else { jo.Add("Result", 0); jo.Add("Message", "密码更换失败"); } } else { jo.Add("Result", 0); jo.Add("Message", "原密码错误"); } } else { jo.Add("Result", 0); jo.Add("Message", "用户名不存在"); } } catch (Exception error) { jo.Add("Result", 3); jo.Add("Message", error.Message); } LoggerHelp.LogInfo("PwdUpdate返回数据:" + jo); return(Json(jo.ToString())); }
public IHttpActionResult GetRegisMsg(object obj) { JObject je = new JObject(); JObject jo = new JObject(); try { string getStr = string.Empty; je = (JObject)JsonConvert.DeserializeObject(obj.ToString()); LoggerHelp.LogInfo("GetRegisMsg接收数据:" + je); //判断一下用户名是否存在是否被注册过 SqlSugarClient sql = datahandle.GetDataConnect(); List <user_login> list_user = sql.Queryable <user_login>().Where(t => t.userName == je["userName"].ToString()).ToList(); if (list_user.Count > 0) { jo.Add("Result", 3); jo.Add("Message", "用户名已存在"); } else { user_login user = new user_login(); user.userName = je["userName"].ToString(); user.userPwd = Md5Control.MD5Encrypt(je["userPwd"].ToString()); user.userID = dataTransfer.StringToHexString(user.userName + je["userPwd"].ToString(), Encoding.UTF8); //user.id = Convert.ToInt32(je["id"].ToString()); int Result = sql.Insertable(user).ExecuteCommand(); if (Result == 1) { jo.Add("Message", "注册成功"); jo.Add("Result", 1); } else { jo.Add("Result", 0); jo.Add("Message", "注册失败"); } } } catch (Exception error) { jo.Add("Result", 4); jo.Add("Message", error.Message); } LoggerHelp.LogInfo("GetRegisMsg返回数据:" + jo); return(Json(jo.ToString())); }
public IHttpActionResult UserLogin(dynamic obj) { JObject je = new JObject(); JObject jo = new JObject(); try { je = (JObject)JsonConvert.DeserializeObject(obj.ToString()); LoggerHelp.LogInfo("UserLogin接收数据:" + Md5Control.MD5Encrypt(je.ToString())); SqlSugarClient sql = datahandle.GetDataConnect(); List <user_login> list_user = sql.Queryable <user_login>().Where(t => t.userName == je["userName"].ToString()).ToList(); if (list_user.Count == 1) { user_login user_Login = list_user[0]; if (user_Login.userPwd == Md5Control.MD5Encrypt(je["userPwd"].ToString())) { jo.Add("Result", 1); jo.Add("Message", "登录成功"); } else { jo.Add("Result", 0); jo.Add("Message", "登录失败,密码错误"); } } else { jo.Add("Result", 2); jo.Add("Message", "用户不存在,请先注册!"); } } catch (Exception error) { jo.Add("Result", -1); jo.Add("Message", error.Message); } LoggerHelp.LogInfo("UserLogin返回数据:" + jo); return(Json(jo.ToString())); }