public UserAppModel GetUserByToken(Dictionary <string, string> form)
        {
            string UUID = Request.Headers["UUID"];
            ISessionTokenService sessionTokenService = servicesFactory.CreateSessionTokenService();
            string uuid = HttpContext.Request.Headers["UUID"];

            if (form != null && form["token"] != null)
            {
                return(sessionTokenService.DecryptToken(uuid, form["token"]));
            }

            throw new Exception("Token Field is Required!");
        }
示例#2
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            if (!string.IsNullOrEmpty(context.HttpContext.Request.Headers["UUID"]) && !string.IsNullOrEmpty(context.HttpContext.Request.Headers["Token"]))
            {
                string uuid        = context.HttpContext.Request.Headers["UUID"];
                string tokenString = context.HttpContext.Request.Headers["Token"];
                ISessionTokenService sessionTokenService = servicesFactory.CreateSessionTokenService();
                UserAppModel         user = sessionTokenService.DecryptToken(uuid, tokenString);

                if (user != null && user.id > 0)
                {
                    return;
                }
            }

            context.Result = new UnauthorizedResult();
            return;
        }