Пример #1
0
        public async Task <IActionResult> AllUserGranted(string AccessToken)
        {
            var target = await _dbContext.AccessToken
                         .SingleOrDefaultAsync(t => t.Value == AccessToken);

            if (target == null)
            {
                return(Json(new ValidateAccessTokenViewModel {
                    code = ErrorType.Unauthorized, message = "We can not validate your access token!"
                }));
            }
            else if (!target.IsAlive)
            {
                return(Json(new ValidateAccessTokenViewModel {
                    code = ErrorType.Timeout, message = "Your access token is already Timeout!"
                }));
            }

            var grants = _dbContext.LocalAppGrant.Include(t => t.User).Where(t => t.AppID == target.ApplyAppId).Take(200);
            var model  = new AllUserGrantedViewModel
            {
                AppId   = target.ApplyAppId,
                Grants  = new List <Grant>(),
                code    = ErrorType.Success,
                message = "Successfully get all your users"
            };

            model.Grants.AddRange(grants);
            return(Json(model));
        }
Пример #2
0
        public async Task <IActionResult> AllUserGranted([Required] string accessToken)
        {
            var appid  = _tokenManager.ValidateAccessToken(accessToken);
            var grants = await _dbContext.LocalAppGrant.Include(t => t.User).Where(t => t.AppID == appid).Take(400).ToListAsync();

            var model = new AllUserGrantedViewModel
            {
                AppId   = appid,
                Grants  = new List <Grant>(),
                Code    = ErrorType.Success,
                Message = "Successfully get all your users"
            };

            model.Grants.AddRange(grants);
            return(Json(model));
        }
        public async Task <IActionResult> AllUserGranted(string AccessToken)
        {
            var target = await _dbContext.AccessToken
                         .SingleOrDefaultAsync(t => t.Value == AccessToken);

            var grants = _dbContext.LocalAppGrant.Include(t => t.User).Where(t => t.AppID == target.ApplyAppId).Take(200);
            var model  = new AllUserGrantedViewModel
            {
                AppId   = target.ApplyAppId,
                Grants  = new List <Grant>(),
                Code    = ErrorType.Success,
                Message = "Successfully get all your users"
            };

            model.Grants.AddRange(grants);
            return(Json(model));
        }