public async Task <ActionResult> ManageScopes(ClientScopeModel model) { if (!ModelState.IsValid) { return(View(model)); } var adminStore = new IdentityServer3AdminStore(); if (model.AllowedScopes != null) { // remove the ones that need to be removed var queryToBeDeleted = (from item in model.AllowedScopes where item.Enabled == false select item.Name).ToList(); if (queryToBeDeleted.Any()) { await adminStore.DeleteScopesFromClientAsync(model.ClientId, queryToBeDeleted); } } if (model.UserScopes != null) { var queryToBeAdded = (from item in model.UserScopes where item.Enabled select item.Name).ToList(); if (queryToBeAdded.Any()) { await adminStore.AddScopesToClientAsync(model.ClientId, queryToBeAdded); } } return(RedirectToAction("ManageScopes", new { clientId = model.ClientId })); }
public async Task <ActionResult> ManageScopes(string clientId) { var adminStore = new IdentityServer3AdminStore(); var userScopes = await adminStore.FindScopesByUserAsync(User.Identity.GetUserId()); var queryUserScopes = from item in userScopes let c = new ScopeEnabledRecord() { Enabled = false, Name = item } select c; var currentClient = await adminStore.FindClientByIdAsync(clientId); var queryAllowedScopes = from item in currentClient.AllowedScopes let c = new ScopeEnabledRecord() { Enabled = true, Name = item } select c; var model = new ClientScopeModel() { ClientId = clientId, UserScopes = queryUserScopes.ToList(), AllowedScopes = queryAllowedScopes.ToList() }; return(View(model)); }