예제 #1
0
        public async Task <IActionResult> GetApplicationsAsync([FromRoute] Guid userId)
        {
            List <Application> applications;

            if (this.UserHasScope(UserScopes.Admin) || userId == this.GetUserId())
            {
                applications = await _getApplicationsService.GetByUserIdAsync(userId);
            }
            else
            {
                throw new ForbiddenException();
            }

            var found = applications.Select(a => ApplicationResponseDto.FromApplication(a, false));

            return(Ok(found));
        }
예제 #2
0
        public async Task <IActionResult> GetAsync()
        {
            List <Application> applications;

            if (this.UserHasScope(ApplicationScopes.Admin))
            {
                applications = await _getApplicationsService.GetAllAsync();
            }
            else
            {
                applications = await _getApplicationsService.GetByUserIdAsync(this.GetUserId());
            }

            var found = applications.Select(ApplicationResponseDto.FromApplication);

            return(Ok(found));
        }