public void ProcessRequest(HttpContext context) { string msg = string.Empty; try { string userName = WebBase.GetFormString("txtusername", string.Empty); string userPwd = WebBase.GetFormString("txtpassword", string.Empty); string ip = WebBase.GetFormString("ip", ServerVariables.TrueIP); if (string.IsNullOrEmpty(userName)) { msg = ("请输入商户名!"); } else if (string.IsNullOrEmpty(userPwd)) { msg = ("请输入商户密码!"); } else { msg = viviapi.BLL.User.Login.SignIn(1, 0, userName, Cryptography.MD5(userPwd), ip, ip); if (msg == "success") { msg = "success," + HttpContext.Current.Session[viviapi.BLL.User.Login.UserLoginSessionid].ToString(); } } } catch { msg = "login fail"; } context.Response.ContentType = "text/plain"; context.Response.Write(msg); }
/// <summary> /// /// </summary> /// <param name="parmName"></param> /// <returns></returns> public string GetParmValue(string parmName) { string parmValue = WebBase.GetQueryStringString(parmName, ""); if (string.IsNullOrEmpty(parmValue)) { parmValue = WebBase.GetFormString(parmName, ""); } return(parmValue); }
public string SignIn() { string message = ""; try { string userName = WebBase.GetFormString("username", ""); string userPwd = WebBase.GetFormString("password", ""); string ispass = WebBase.GetFormString("ckbsavepass", ""); string code = WebBase.GetFormString("imycode", ""); if (string.IsNullOrEmpty(code)) { message = ("请输入验证码!"); } else if (string.IsNullOrEmpty(userName)) { message = ("请输入商户名!"); } else if (string.IsNullOrEmpty(userPwd)) { message = ("请输入商户密码!"); } else { message = WebUtility.CheckValiDateCode(code); } if (string.IsNullOrEmpty(message)) { string lastLoginIp = ServerVariables.TrueIP; string lastLoginAddress = WebUtility.GetIPAddress(lastLoginIp); message = viviapi.BLL.User.Login.SignIn(0, 0, userName, Cryptography.MD5(userPwd), lastLoginIp, lastLoginAddress); if (message == "success") { if (ispass != null) { HttpCookie hc = new HttpCookie("yklm_user"); DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟 hc.Expires = dt.Add(ts); //设置过期时间 //hc.Values.Add("username", userName); hc.Values.Add("userpass", Cryptography.MD5(userPwd)); Response.AppendCookie(hc); } else { HttpCookie hc = new HttpCookie("yklm_user"); hc.Expires = DateTime.Now.AddMonths(-24); Response.Cookies.Add(hc); } } } } catch (Exception exception) { ExceptionHandler.HandleException(exception); message = exception.Message; } return(message); }
private void SignIn() { string message = ""; string userName = XRequest.GetString("username"); string passWord = XRequest.GetString("password"); string code = XRequest.GetString("CCode"); string RememberMe = WebBase.GetFormString("RememberMe", ""); if (string.IsNullOrEmpty(code)) { message = ("请输入验证码!"); } else if (string.IsNullOrEmpty(userName)) { message = ("请输入代理账号!"); } else if (string.IsNullOrEmpty(passWord)) { message = ("请输入代理密码!"); } else { message = WebUtility.CheckValiDateCode(code); } if (string.IsNullOrEmpty(message)) { string lastLoginIp = ServerVariables.TrueIP; string lastLoginAddress = WebUtility.GetIPAddress(lastLoginIp); message = viviapi.BLL.User.Login.SignIn(0, 1, userName, Cryptography.MD5(passWord), lastLoginIp, lastLoginAddress); if (message == "success") { if (viviapi.BLL.User.Login.CurrentMember.UserType == UserTypeEnum.代理) { if (RememberMe != null) { HttpCookie hc = new HttpCookie("yklm_agent"); DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟 hc.Expires = dt.Add(ts); //设置过期时间 hc.Values.Add("username", userName); Response.AppendCookie(hc); } else { HttpCookie hc = new HttpCookie("yklm_agent"); hc.Expires = DateTime.Now.AddMonths(-24); Response.Cookies.Add(hc); } } else { message = ("非代理权限,无法登录!"); } } } if (message == "success") { Response.Redirect("main.aspx"); } else { ShowMessageBox(message); } }
public string GetValue(string key) { return(WebBase.GetFormString(key, "")); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.Cookies["yklm_admin"] != null) { //UserNameBox.Value = Request.Cookies["yklm_admin"]["username"].ToString(); //password.Attributes["value"] = "**********"; } } if (XRequest.IsPost()) { string code = XRequest.GetString("CCode").ToUpper(); string secode = this.Session["CCode"].ToString().ToUpper(); if (this.Session["CCode"] == null) { AlertAndRedirect("验证码已失效!"); return; } else if (XRequest.GetString("CCode").ToUpper() != this.Session["CCode"].ToString().ToUpper()) { AlertAndRedirect("验证码错误!"); return; } else { string userName = XRequest.GetString("UserNameBox"); string passWord = Cryptography.MD5(XRequest.GetString("pas")); string RememberMe = WebBase.GetFormString("RememberMe", ""); Model.Manage manage = new viviapi.Model.Manage(); manage.username = userName; manage.password = passWord; manage.lastLoginTime = DateTime.Now; manage.lastLoginIp = viviLib.Web.ServerVariables.TrueIP; manage.LastLoginAddress = WebUtility.GetIPAddress(manage.lastLoginIp); manage.LastLoginRemark = WebUtility.GetIPAddressInfo(manage.lastLoginIp); string message = BLL.ManageFactory.SignIn(manage); if (manage.id > 0) { if (RememberMe != null) { HttpCookie hc = new HttpCookie("yklm_admin"); DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟 hc.Expires = dt.Add(ts); //设置过期时间 hc.Values.Add("username", userName); Response.AppendCookie(hc); } else { HttpCookie hc = new HttpCookie("yklm_admin"); hc.Expires = DateTime.Now.AddMonths(-24); Response.Cookies.Add(hc); } AlertAndRedirect(string.Empty, "main.aspx"); } else { AlertAndRedirect(message); } } } }
protected void Page_Load(object sender, EventArgs e) { string message = ""; string userName = WebBase.GetFormString("username", ""); string userPwd = WebBase.GetFormString("password", ""); string code = WebBase.GetFormString("login_yzcode", ""); if (string.IsNullOrEmpty(userName)) { message = ("请输入用户名!"); } else if (string.IsNullOrEmpty(userPwd)) { message = ("请输入密码!"); } if (string.IsNullOrEmpty(message)) { if (viviLib.Text.PageValidate.IsEmail(userName)) { if (!RegisterSettings.AllowUserloginByEmail) { message = ("平台不允许通过邮箱登录!"); } } else if (viviLib.Text.PageValidate.IsMobile(userName)) { if (!RegisterSettings.AllowUserloginByPhone) { message = ("平台不允许通过手机号码登录!"); } } } if (string.IsNullOrEmpty(message)) { string lastLoginIp = ServerVariables.TrueIP; string lastLoginAddress = WebUtility.GetIPAddress(lastLoginIp); message = viviapi.BLL.User.Login.SignIn(0, 0, userName, Cryptography.MD5(userPwd), lastLoginIp, lastLoginAddress); if (message == "success") { HttpCookie hc = new HttpCookie("yklm_user"); DateTime dt = DateTime.Now; TimeSpan ts = new TimeSpan(90, 0, 0, 0, 0); //过期时间为1分钟 hc.Expires = dt.Add(ts); //设置过期时间 hc.Values.Add("username", userName); hc.Values.Add("userpass", Cryptography.MD5(userPwd)); HttpContext.Current.Response.AppendCookie(hc); string response = "{\"code\":200,\"error_num\":0}"; Response.Write(response); } else { string response = "{\"code\":0,\"data\":{\"error_messages\":{\"result\":\"error2\"}},\"error_num\":0}"; Response.Write(response); } } else { Response.Write("{\"code\":0,\"data\":{\"error_messages\":{\"result\":\"error\"}},\"error_num\":0}"); } }