コード例 #1
0
        protected internal virtual async Task <GrantsViewModel> CreateGrantsViewModelAsync()
        {
            var model  = new GrantsViewModel();
            var grants = await this.Facade.Interaction.GetAllUserGrantsAsync();

            foreach (var grant in grants)
            {
                var client = await this.Facade.ClientStore.FindClientByIdAsync(grant.ClientId);

                if (client == null)
                {
                    continue;
                }

                var resources = await this.ResourceStore.FindResourcesByScopeAsync(grant.Scopes);

                var item = new GrantViewModel()
                {
                    Client      = client,
                    Created     = grant.CreationTime,
                    Description = grant.Description,
                    Expiration  = grant.Expiration,
                };

                item.ApiScopes.Add(resources.ApiScopes.ToArray());
                item.IdentityResources.Add(resources.IdentityResources.ToArray());

                model.Grants.Add(item);
            }

            return(model);
        }
コード例 #2
0
        private async Task <GrantsViewModel> BuildViewModelAsync()
        {
            var grants = await _interaction.GetAllUserConsentsAsync();

            var list = new List <GrantViewModel>();

            foreach (var grant in grants)
            {
                var client = await _clients.FindClientByIdAsync(grant.ClientId);

                if (client != null)
                {
                    var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes);

                    var item = new GrantViewModel()
                    {
                        ClientId           = client.ClientId,
                        ClientName         = client.ClientName ?? client.ClientId,
                        ClientLogoUrl      = client.LogoUri,
                        ClientUrl          = client.ClientUri,
                        Created            = grant.CreationTime,
                        Expires            = grant.Expiration,
                        IdentityGrantNames = resources.IdentityResources.Select(x => x.DisplayName ?? x.Name).ToArray(),
                        ApiGrantNames      = resources.ApiResources.Select(x => x.DisplayName ?? x.Name).ToArray()
                    };

                    list.Add(item);
                }
            }
            GrantsViewModel = new GrantsViewModel
            {
                Grants = list
            };
            return(GrantsViewModel);
        }
コード例 #3
0
        public async Task <IActionResult> OnPostRevokeAsync(string clientId)
        {
            await _interaction.RevokeUserConsentAsync(clientId);

            await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), clientId));

            this.GrantsViewModel = await BuildViewModelAsync();

            return(Page());
        }
 public async void OnGetAsync()
 {
     GrantsViewModel = await BuildViewModelAsync();
 }
コード例 #5
0
 public async Task OnGet()
 {
     this.GrantsViewModel = await BuildViewModelAsync();
 }