Пример #1
0
        public async Task <ActionResult> New(ClientViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Client client = new Client()
            {
                AccessTokenType = model.AccessTokenType,
                Enabled         = model.Enabled,
                AllowedScopes   = model.AllowedScopes,
                ClientId        = model.ClientId,
                ClientName      = model.ClientName,
                ClientSecrets   = model.ClientSecrets,
                Flow            = model.Flow
            };
            var adminStore = new IdentityServer3AdminStore();
            await adminStore.CreateClientAsync(client);

            var clients = new List <string> {
                client.ClientId
            };
            await adminStore.AddClientIdToIdentityServerUserAsync(User.Identity.GetUserId(), clients);

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public async Task <ActionResult> Manage(ClientViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var adminStore = new IdentityServer3AdminStore();
            var client     = await adminStore.FindClientByIdAsync(model.ClientId);

            client.ClientName = model.ClientName;
            client.Enabled    = model.Enabled;

            await adminStore.CreateClientAsync(client);

            var clients = new List <string> {
                client.ClientId
            };
            await adminStore.AddClientIdToIdentityServerUserAsync(User.Identity.GetUserId(), clients);

            return(RedirectToAction("Index"));
        }