Exemplo n.º 1
0
        public ActionResult Login(string userName, string password)
        {
            string token = JWThelper.Encrypt(userName);

            Response.SetCookie(new HttpCookie("token", token));
            return(Redirect("~/User/Chat"));
        }
Exemplo n.º 2
0
        // 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());
        }