Exemplo n.º 1
0
        public ActionResult UserHome()
        {
            ViewBag.Title = "UserHome";
            var cookie = Request.Cookies.Get("auth");

            if (cookie != null)
            {
                UserManipulate um = new UserManipulate();
                if (!um.IsLogedIn(cookie.Value))
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View());
        }
Exemplo n.º 2
0
        // Post: User
        public User GetUser()
        {
            string            userAuth;
            CookieHeaderValue cookie1 = Request.Headers.GetCookies("auth").FirstOrDefault();

            if (cookie1 != null)
            {
                UserManipulate um = new UserManipulate();
                userAuth = cookie1["auth"].Value;

                if (um.IsLogedIn(userAuth))
                {
                    User user = um.getUserIdFromAuthToken(userAuth);
                    user.Password = null;

                    return(user);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }