public ActionResult Login(string userName, string password) { string token = JWThelper.Encrypt(userName); Response.SetCookie(new HttpCookie("token", token)); return(Redirect("~/User/Chat")); }
// GET: User public ActionResult Chat() { var token = Request.Cookies["token"]; if (token == null) { return(Redirect("~/User/Login")); } var username = JWThelper.Decrypt(token.Value); if (string.IsNullOrEmpty(username) && username == "yuezhang") { return(Redirect("~/User/Login")); } return(View()); }