public ActionResult Login(string username, string password) { try { DbContext currentDb = SysContext.GetCurrentDb(); if (SysContext.EnabledMD5Password) { password = HashHelper.GetMd5(password); } bool flag = false; flag = currentDb.Exists <core_user>("Loginname = @0 and LoginPassword = @1", new object[2] { username, password }); Regex regex = new Regex("^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"); if (regex.IsMatch(username)) { if (flag = currentDb.Exists <core_user>("Email = @0 and LoginPassword = @1", new object[2] { username, password })) { username = currentDb.ExecuteScalar <string>("select Loginname from core_user where Email = @0 and LoginPassword = @1", new object[2] { username, password }); } } else { flag = currentDb.Exists <core_user>("Loginname = @0 and LoginPassword = @1", new object[2] { username, password }); } if (flag) { currentDb.ExecuteScalar <string>("select ID from core_user where Loginname = @0 and LoginPassword = @1", new object[2] { username, password }); HttpCookie httpCookie = new HttpCookie(cookie_user); httpCookie.Path = "/"; httpCookie.Value = SSOHelper.CreateContextValue(username, password); httpCookie.Expires = DateTime.Now.AddHours(2.0); CookieHelper.SetCookie(httpCookie); } return(Json(new { statusCode = "1", data = flag })); } catch (Exception ex) { return(Json(new { statusCode = "3", message = ex.Message })); } }