public override void ExecuteHandle(HttpContext context, StringBuilder resContent) { var txtmobile = Check(context.Request["Mobile"]); var txtpwd = context.Request["PassWord"]; var txtName = context.Request["Name"]; var mobileAny = DB.Queryable <YoHao.Model.User.User>().Where(it => it.Mobile == txtmobile).Any(); if (mobileAny) { resContent.Append("\"status\":\"n\", \"info\":\"注册失败手机号已存在!\""); base.ExecuteHandle(context, resContent); return; } var user = new YoHao.Model.User.User { PassWord = StringHelper.MD5(txtpwd), Name = txtName, Mobile = txtmobile, CreateTime = DateTime.Now, Info = "", Sessionid = context.Session.SessionID }; var t3 = DB.Insertable(user).ExecuteReturnEntity(); var authuer = new AuthUser() { Id = t3.Id, Name = t3.Name, Sessionid = t3.Sessionid }; authuer.SetTicket(HttpContext.Current); resContent.Append("\"status\":\"y\", \"info\":\"注册成功!\""); base.ExecuteHandle(context, resContent); }
public override void ExecuteHandle(HttpContext context, StringBuilder resContent) { var txtval = context.Request["Mobile"].Trim(); var txtpwd = context.Request["PassWord"].Trim(); if (!string.IsNullOrEmpty(txtval) && !string.IsNullOrEmpty(txtpwd)) { string sqlWhere; if (txtval.Length == 11 && DataValidate.IsNumberic(txtval)) { sqlWhere = $" Mobile='{txtval}'"; } else { sqlWhere = $" PassWord='******' "; } sqlWhere += $" and password='******'"; User = DB.Queryable <User>().Single(p => p.Mobile == txtval && p.PassWord == StringHelper.MD5(txtpwd)); if (User == null) { resContent.Append("\"status\":\"n\", \"info\":\"该登录账号或密码错误!\""); return; } //普通用户登录 User.Sessionid = context.Session.SessionID; DB.Updateable(User); var authuer = new AuthUser() { Id = User.Id, Name = User.Name, Sessionid = User.Sessionid }; authuer.SetTicket(HttpContext.Current); resContent.Append("\"status\":\"y\", \"info\":\"登录成功!\",\"type\":" + "1"); } else { resContent.Append("\"status\":\"n\", \"info\":\"请输入登录信息!\""); } base.ExecuteHandle(context, resContent); }