Ejemplo n.º 1
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);
                }
            }

            return(new GrantsViewModel
            {
                Grants = list
            });
        }
Ejemplo n.º 2
0
        private async Task <GrantsViewModel> BuildViewModelAsync()
        {
            IEnumerable <IdentityServer4.Models.Consent> grants = await _interaction.GetAllUserConsentsAsync();

            List <GrantViewModel> list = new List <GrantViewModel>();

            foreach (IdentityServer4.Models.Consent grant in grants)
            {
                await NewMethod(list, grant);
            }

            return(new GrantsViewModel
            {
                Grants = list
            });
        }
Ejemplo n.º 3
0
        private async Task <GrantsViewModel> BuildViewModelAsync()
        {
            var grants = await _interaction.GetAllUserConsentsAsync();

            var connectionstring = GetConnectionString();

            var optionsBuilder = new DbContextOptionsBuilder <ConfigurationDbContext>();

            optionsBuilder.UseSqlServer(connectionstring);

            var configurationStoreBuilder = new ConfigurationStoreOptions();

            configurationStoreBuilder.ConfigureDbContext = b => b.UseSqlServer(connectionstring
                                                                               );
            ConfigurationDbContext dbContext = new ConfigurationDbContext(optionsBuilder.Options, configurationStoreBuilder);
            var clients = dbContext.Clients.ToList <Client>();


            var list = new List <GrantViewModel>();

            foreach (var client in clients)
            {
                if (client != null)
                {
                    var item = new GrantViewModel()
                    {
                        ClientId      = client.ClientId,
                        ClientName    = client.ClientId,
                        ClientLogoUrl = client.LogoUri,
                        ClientUrl     = client.ClientUri,
                        Created       = client.Created
                    };

                    list.Add(item);
                }
            }

            return(new GrantsViewModel
            {
                Grants = list
            });
        }