public object Login(string account, string password) { try { var re = UserServer.Login(account, password); //如果登陆成功 设置session if (re != "login successful") { return new { msg = re } } ; var user = UserServer.GetUser(account); HttpContext.Session.SetString("user_Account", account); HttpContext.Session.SetString("user_Password", user.password); HttpContext.Session.SetString("user_Type", user.userType); HttpContext.Session.SetString("user_Province", user.province); HttpContext.Session.SetString("user_phoneNumber", user.phoneNumber); return(new { msg = re }); } catch (Exception e) { return(new { msg = e.Message }); } }
public object Login([FromBody] LoginModel lm) { try { // var addr = Server.GetUserIp(Request.HttpContext); // // if (Server.IpHandle(addr) == 0) // { // return new[] { "your ip can't using our api , please contact administrator" }; // } var verCode = HttpContext.Session.GetString("user_verCode"); if (verCode == null) { return(new { result = 401, msg = "verCode session is null" }); } if (verCode != lm.VerCode) { return(new { result = 401, msg = "wrong verCode", veC = verCode, subVec = lm.VerCode }); } var re = UserServer.Login(lm); if (re.result == 200) { HttpContext.Session.Remove("user_verCode"); HttpContext.Session.SetString("user_account", lm.Account); } return(re); } catch (Exception e) { return(new { result = e.HResult, msg = e.Message }); } }
public object Login(string account, string password) { try { var addr = Server.GetUserIp(Request.HttpContext); if (Server.IPHandle(addr) == 0) { return(new { msg = "your ip can't using our api , please contact administrator" }); } var re = UserServer.Login(account, password); return(new { msg = re }); } catch (Exception e) { return(new { msg = e.Message }); } }
public object Login([FromBody] LoginModel um) { try { var re = UserServer.Login(um.Account, um.Password); //如果登陆成功 设置session var user = UserServer.GetUser(um.Account); HttpContext.Session.SetString("user_Account", um.Account); HttpContext.Session.SetString("user_Password", user.password); HttpContext.Session.SetString("user_Type", user.userType); HttpContext.Session.SetString("user_Province", user.province); HttpContext.Session.SetString("user_phoneNumber", user.phoneNumber); return(new { msg = re }); } catch (Exception e) { return(new { msg = e.Message }); } }