Exemple #1
0
        public async Task <IActionResult> GetProject([FromHeader] string token)
        {
            //token验证   并且取回对应的值
            var result = (new TokenValidate()).CheckToken(token, _cache);

            if (result.CheckParamsSuccess == "no")
            {
                return(Json(result));
            }
            var user = UserCommom.getUserInfo(_cache, token, _context);

            //判断是否是管理员
            if (user.AdminScopeIdentifier == 1)
            {
                //如果是管理员   则查询所有项目
                var project = _context.Projects.AsNoTracking().;
            }
            else
            {
                //查看该会员对应的项目
                var Project = _context.Projects.Where(p => p.JoinUser.Contains(user.Id + "")).ToList();
            }
            //返回该返回的数据
            return(Ok());
        }
            //判断用户token是否登录或者token是否失效
            public void OnAuthorization(AuthorizationFilterContext context)
            {
                string token = context.HttpContext.Request.Headers["token"];
                string path  = context.HttpContext.Request.Path;

                UserCommom checklogin = new UserCommom();
                ReturnJson result     = checklogin.CheckLogin(path, token, _cache);

                if (result.CheckParamsSuccess == "no")
                {
                    context.Result = new ObjectResult(result);
                }
            }