From e321bc3cc78c8696b8dcae36d29d4d4e3974436c Mon Sep 17 00:00:00 2001 From: thabart Date: Tue, 12 Mar 2024 14:24:19 +0100 Subject: [PATCH] Ticket #710 : Fix some issues --- .../Pages/ScopeResources.razor | 193 ++++++++++++------ .../Resources/Global.Designer.cs | 18 ++ .../Resources/Global.resx | 6 + .../ApiResourceStore/ApiResourceEffects.cs | 46 ++++- .../ApiResourceStore/ApiResourceReducers.cs | 132 +++++++++--- .../ApiResourceStore/ApiResourcesState.cs | 40 ++++ .../SearchApiResourcesState.cs | 36 ---- .../Stores/Auditing/AuditingRecordEffects.cs | 6 +- .../UI/BaseAuthenticationMethodController.cs | 1 + .../UI/HomeController.cs | 2 +- 10 files changed, 353 insertions(+), 127 deletions(-) create mode 100644 src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourcesState.cs delete mode 100644 src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/SearchApiResourcesState.cs diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Pages/ScopeResources.razor b/src/IdServer/SimpleIdServer.IdServer.Website/Pages/ScopeResources.razor index 66b6a6e05..bcb08a1c4 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Pages/ScopeResources.razor +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Pages/ScopeResources.razor @@ -7,57 +7,100 @@ @inject ContextMenuService contextMenuService @inject DialogService dialogService @inject IDispatcher dispatcher -@inject IState searchApiResourcesState +@inject IState searchApiResourcesState @inject NotificationService notificationService
-

@((MarkupString)(Global.ScopeResourcesDescription))

- - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + + + + + + + Unassign()) ButtonStyle="ButtonStyle.Primary" /> + + + + + + + + + + + + + + + + + + +
@code { - bool selectAll = false; + bool selectAllAvailable = false; + bool selectAllActive = false; RadzenDataGrid grid; [Parameter] @@ -73,6 +116,11 @@ notificationService.Notify(new NotificationMessage { Severity = NotificationSeverity.Success, Summary = Global.ScopeResourcesUpdated }); StateHasChanged(); }); + SubscribeToAction((act) => + { + notificationService.Notify(new NotificationMessage { Severity = NotificationSeverity.Success, Summary = Global.ScopeResourcesUpdated }); + StateHasChanged(); + }); SubscribeToAction((act) => { notificationService.Notify(new NotificationMessage { Severity = NotificationSeverity.Success, Summary = Global.ScopeResourcesRemoved }); @@ -82,15 +130,27 @@ } } - void ToggleChanged(bool isSelected, SelectableApiResource apiResource) + void ToggleAvailableChanged(bool isSelected, SelectableApiResource apiResource) { - var act = new ToggleApiResourceSelectionAction { IsSelected = isSelected, ResourceName = apiResource.Value.Name }; + var act = new ToggleAvailableApiResourceSelectionAction { IsSelected = isSelected, ResourceName = apiResource.Value.Name }; dispatcher.Dispatch(act); } - void ToggleAll(bool isSelected) + void ToggleActiveChanged(bool isSelected, SelectableApiResource apiResource) { - var act = new ToggleAllApiResourceSelectionAction { IsSelected = isSelected }; + var act = new ToggleActiveApiResourceSelectionAction { IsSelected = isSelected, ResourceName = apiResource.Value.Name }; + dispatcher.Dispatch(act); + } + + void ToggleAvailableAll(bool isSelected) + { + var act = new ToggleAllAvailableApiResourceSelectionAction { IsSelected = isSelected }; + dispatcher.Dispatch(act); + } + + void ToggleActiveAll(bool isSelected) + { + var act = new ToggleAllActiveApiResourceSelectionAction { IsSelected = isSelected }; dispatcher.Dispatch(act); } @@ -105,21 +165,19 @@ row.Attributes.Remove(className); } - void ShowMoreContextMenu(SelectableApiResource resource, MouseEventArgs args) + void Unassign() { - contextMenuService.Open(args, new List - { - new ContextMenuItem { Text = Global.Delete, Value = 1 } - }, (a) => + var apiResources = searchApiResourcesState.Value.ActiveApiResources.Where(r => !r.IsSelected).Select(r => r.Value.Name).ToList(); + var act = new UnassignApiResourcesAction { Id = Scope.Id, Resources = apiResources }; + dispatcher.Dispatch(act); + } + + void Assign() { - if (a.Value.Equals(1)) - { - var resourceIds = searchApiResourcesState.Value.ApiResources.Where(s => s.IsSelected).Select(s => s.Value.Id).ToList(); - var act = new RemoveSelectedApiResourcesAction { ResourceIds = resourceIds }; - dispatcher.Dispatch(act); - contextMenuService.Close(); - } - }); + var selectedApiResources = searchApiResourcesState.Value.AvailableApiResources.Where(r => r.IsSelected).Select(r => r.Value.Name); + var apiResources = searchApiResourcesState.Value.ActiveApiResources.Select(r => r.Value.Name).ToList(); + apiResources.AddRange(selectedApiResources); + dispatcher.Dispatch(new UpdateApiScopeResourcesAction { Id = Scope.Id, Resources = apiResources }); } void LoadData(LoadDataArgs args) @@ -128,6 +186,23 @@ dispatcher.Dispatch(act); } + void ShowMoreContextMenu(SelectableApiResource resource, MouseEventArgs args) + { + contextMenuService.Open(args, new List + { + new ContextMenuItem { Text = Global.Delete, Value = 1 } + }, (a) => + { + if (a.Value.Equals(1)) + { + var resourceIds = searchApiResourcesState.Value.AvailableApiResources.Where(s => s.IsSelected).Select(s => s.Value.Id).ToList(); + var act = new RemoveSelectedApiResourcesAction { ResourceIds = resourceIds }; + dispatcher.Dispatch(act); + contextMenuService.Close(); + } + }); + } + async void AddResource() { await dialogService.OpenAsync(Global.AddApiResource, new Dictionary(), new DialogOptions @@ -138,10 +213,4 @@ Draggable = true }); } - - void UpdateResource() - { - var selectedApiResources = searchApiResourcesState.Value.ApiResources.Where(r => r.IsSelected).Select(r => r.Value.Name); - dispatcher.Dispatch(new UpdateApiScopeResourcesAction { Id = Scope.Id, Resources = selectedApiResources }); - } } \ No newline at end of file diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.Designer.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.Designer.cs index aea193be2..b30cd6e48 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.Designer.cs +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.Designer.cs @@ -438,6 +438,15 @@ public static string AssignGroups { } } + /// + /// Recherche une chaîne localisée semblable à Assign. + /// + public static string AssignResources { + get { + return ResourceManager.GetString("AssignResources", resourceCulture); + } + } + /// /// Recherche une chaîne localisée semblable à At least one redirection URL must be specified. /// @@ -4305,6 +4314,15 @@ public static string Unassign { } } + /// + /// Recherche une chaîne localisée semblable à Unassign. + /// + public static string UnassignResources { + get { + return ResourceManager.GetString("UnassignResources", resourceCulture); + } + } + /// /// Recherche une chaîne localisée semblable à The client '{0}' doesn't exist. /// diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.resx b/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.resx index 39b57a846..ffb11805e 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.resx +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Resources/Global.resx @@ -1758,4 +1758,10 @@ The <b>authorization_signed_response_alg</b> will be set to <b> WS-Federation application + + Assign + + + Unassign + \ No newline at end of file diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceEffects.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceEffects.cs index 3d558b2a8..8e2fbae82 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceEffects.cs +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceEffects.cs @@ -126,6 +126,25 @@ public async Task Handle(UpdateApiScopeResourcesAction action, IDispatcher dispa dispatcher.Dispatch(new UpdateApiScopeResourcesSuccessAction { Id = action.Id, Resources = action.Resources }); } + [EffectMethod] + public async Task Handle(UnassignApiResourcesAction action, IDispatcher dispatcher) + { + var baseUrl = await GetScopesBaseUrl(); + var httpClient = await _websiteHttpClientFactory.Build(); + var addRequest = new UpdateScopeResourcesRequest + { + Resources = action.Resources + }; + var requestMessage = new HttpRequestMessage + { + Method = HttpMethod.Put, + RequestUri = new Uri($"{baseUrl}/{action.Id}/resources"), + Content = new StringContent(JsonSerializer.Serialize(addRequest), Encoding.UTF8, "application/json") + }; + await httpClient.SendAsync(requestMessage); + dispatcher.Dispatch(new UnassignApiResourcesSuccessAction { Id = action.Id, Resources = action.Resources }); + } + private Task GetApiResourcesBaseUrl() => GetBaseUrl("apiresources"); private Task GetScopesBaseUrl() => GetBaseUrl("scopes"); @@ -180,13 +199,24 @@ public class AddApiResourceFailureAction public string ErrorMessage { get; set; } = null!; } - public class ToggleApiResourceSelectionAction + public class ToggleAvailableApiResourceSelectionAction + { + public bool IsSelected { get; set; } = false; + public string ResourceName { get; set; } = null!; + } + + public class ToggleActiveApiResourceSelectionAction { public bool IsSelected { get; set; } = false; public string ResourceName { get; set; } = null!; } - public class ToggleAllApiResourceSelectionAction + public class ToggleAllAvailableApiResourceSelectionAction + { + public bool IsSelected { get; set; } = false; + } + + public class ToggleAllActiveApiResourceSelectionAction { public bool IsSelected { get; set; } = false; } @@ -203,6 +233,18 @@ public class UpdateApiScopeResourcesSuccessAction public IEnumerable Resources { get; set; } = new List(); } + public class UnassignApiResourcesAction + { + public string Id { get; set; } = null!; + public IEnumerable Resources { get; set; } = new List(); + } + + public class UnassignApiResourcesSuccessAction + { + public string Id { get; set; } = null!; + public IEnumerable Resources { get; set; } = new List(); + } + public class RemoveSelectedApiResourcesAction { public IEnumerable ResourceIds { get; set; } diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceReducers.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceReducers.cs index c621d2fad..75caea2a9 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceReducers.cs +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourceReducers.cs @@ -10,70 +10,154 @@ public class ApiResourceReducers #region SearchApiResourcesState [ReducerMethod] - public static SearchApiResourcesState ReduceSearchApiResourcesAction(SearchApiResourcesState state, SearchApiResourcesAction act) => new(isLoading: true, apiResources: new List()); + public static ApiResourcesState ReduceSearchApiResourcesAction(ApiResourcesState state, SearchApiResourcesAction act) => new( + isLoading: true, + availableApiResources: new List(), + activeApiResources: new List()); [ReducerMethod] - public static SearchApiResourcesState ReduceSearchApiResourcesSuccessAction(SearchApiResourcesState state, SearchApiResourcesSuccessAction act) + public static ApiResourcesState ReduceSearchApiResourcesSuccessAction(ApiResourcesState state, SearchApiResourcesSuccessAction act) { - var apiResources = act.ApiResources.Select(c => new SelectableApiResource(c)).ToList(); - foreach (var apiResource in apiResources) - apiResource.IsSelected = act.SelectedApiResources.Contains(apiResource.Value.Name); - + var allApiResources = act.ApiResources.Select(c => new SelectableApiResource(c)).ToList(); + var availableApiResources = allApiResources.Where(a => !act.SelectedApiResources.Contains(a.Value.Name)); + var activeApiResources = allApiResources.Where(a => act.SelectedApiResources.Contains(a.Value.Name)); return state with { IsLoading = false, - ApiResources = apiResources, - Count = act.Count + AvailableApiResources = availableApiResources, + AvailableCount = availableApiResources.Count(), + ActiveApiResources = activeApiResources, + ActiveCount = activeApiResources.Count(), }; } [ReducerMethod] - public static SearchApiResourcesState ReduceAddApiResourceSuccessAction(SearchApiResourcesState state, AddApiResourceSuccessAction act) + public static ApiResourcesState ReduceAddApiResourceSuccessAction(ApiResourcesState state, AddApiResourceSuccessAction act) { - var apiResources = state.ApiResources.ToList(); + var availableApiResources = state.AvailableApiResources.ToList(); var newApiResource = new ApiResource { Id = act.Id, CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, Name = act.Name, Description = act.Description, Audience = act.Audience }; - apiResources.Add(new SelectableApiResource(newApiResource) { IsNew = true }); + availableApiResources.Add(new SelectableApiResource(newApiResource) { IsNew = true }); + return state with + { + AvailableApiResources = availableApiResources, + AvailableCount = availableApiResources.Count(), + IsLoading = false + }; + } + + [ReducerMethod] + public static ApiResourcesState ReduceRemoveSelectedApiResourcesSuccessAction(ApiResourcesState state, RemoveSelectedApiResourcesSuccessAction act) + { + var availableApiResources = state.AvailableApiResources.ToList(); + availableApiResources = availableApiResources.Where(r => !act.ResourceIds.Contains(r.Value.Id)).ToList(); + foreach (var resource in availableApiResources) resource.IsSelected = false; + return state with + { + AvailableApiResources = availableApiResources, + AvailableCount = availableApiResources.Count, + IsLoading = false + }; + } + + [ReducerMethod] + public static ApiResourcesState ReduceUpdateApiScopeResourcesSuccessAction(ApiResourcesState state, UpdateApiScopeResourcesSuccessAction act) + { + var activeApiResources = state.ActiveApiResources.ToList(); + var availableApiResources = state.AvailableApiResources.ToList(); + var removedApiResources = availableApiResources.Where(r => act.Resources.Contains(r.Value.Name)).ToList(); + activeApiResources.AddRange(removedApiResources); + availableApiResources = activeApiResources.Where(r => !act.Resources.Contains(r.Value.Name)).ToList(); + foreach (var resource in activeApiResources) resource.IsSelected = false; + foreach (var resource in availableApiResources) resource.IsSelected = false; + return state with + { + ActiveApiResources = activeApiResources, + ActiveCount = activeApiResources.Count, + AvailableApiResources = availableApiResources, + AvailableCount = availableApiResources.Count, + IsLoading = false + }; + } + + [ReducerMethod] + public static ApiResourcesState ReduceUnassignApiResourcesSuccessAction(ApiResourcesState state, UnassignApiResourcesSuccessAction act) + { + var activeApiResources = state.ActiveApiResources.ToList(); + var availableApiResources = state.AvailableApiResources.ToList(); + var removedApiResources = activeApiResources.Where(r => !act.Resources.Contains(r.Value.Name)).ToList(); + availableApiResources.AddRange(removedApiResources); + activeApiResources = activeApiResources.Where(r => act.Resources.Contains(r.Value.Name)).ToList(); + foreach (var resource in activeApiResources) resource.IsSelected = false; + foreach (var resource in availableApiResources) resource.IsSelected = false; return state with { - ApiResources = apiResources, - Count = apiResources.Count() + ActiveApiResources = activeApiResources, + ActiveCount = activeApiResources.Count, + AvailableApiResources = availableApiResources, + AvailableCount = availableApiResources.Count, + IsLoading = false }; } [ReducerMethod] - public static SearchApiResourcesState ReduceRemoveSelectedApiResourcesSuccessAction(SearchApiResourcesState state, RemoveSelectedApiResourcesSuccessAction act) + public static ApiResourcesState ReduceToggleActiveApiResourceSelectionAction(ApiResourcesState state, ToggleActiveApiResourceSelectionAction act) { - var apiResources = state.ApiResources.ToList(); - apiResources = apiResources.Where(r => !act.ResourceIds.Contains(r.Value.Id)).ToList(); + var resources = state.ActiveApiResources?.ToList(); + if (resources == null) return state; + var selectedResource = resources.Single(c => c.Value.Name == act.ResourceName); + selectedResource.IsSelected = act.IsSelected; + return state with + { + ActiveApiResources = resources + }; + } + + [ReducerMethod] + public static ApiResourcesState ReduceToggleActiveAllAvailableApiResourceSelectionAction(ApiResourcesState state, ToggleAllAvailableApiResourceSelectionAction act) + { + var resources = state.AvailableApiResources?.ToList(); + if (resources == null) return state; + foreach (var resource in resources) resource.IsSelected = act.IsSelected; + return state with + { + AvailableApiResources = resources + }; + } + + [ReducerMethod] + public static ApiResourcesState ReduceToggleActiveAllActiveApiResourceSelectionAction(ApiResourcesState state, ToggleAllActiveApiResourceSelectionAction act) + { + var resources = state.ActiveApiResources?.ToList(); + if (resources == null) return state; + foreach (var resource in resources) resource.IsSelected = act.IsSelected; return state with { - ApiResources = apiResources, - Count = apiResources.Count() + ActiveApiResources = resources }; } [ReducerMethod] - public static SearchApiResourcesState ReduceToggleApiResourceSelectionAction(SearchApiResourcesState state, ToggleApiResourceSelectionAction act) + public static ApiResourcesState ReduceToggleAvailableApiResourceSelectionAction(ApiResourcesState state, ToggleAvailableApiResourceSelectionAction act) { - var resources = state.ApiResources?.ToList(); + var resources = state.AvailableApiResources?.ToList(); if (resources == null) return state; var selectedResource = resources.Single(c => c.Value.Name == act.ResourceName); selectedResource.IsSelected = act.IsSelected; return state with { - ApiResources = resources + AvailableApiResources = resources }; } [ReducerMethod] - public static SearchApiResourcesState ReduceToggleAllApiResourceSelectionAction(SearchApiResourcesState state, ToggleAllApiResourceSelectionAction act) + public static ApiResourcesState ReduceToggleAvailableAllApiResourceSelectionAction(ApiResourcesState state, ToggleAllAvailableApiResourceSelectionAction act) { - var resources = state.ApiResources?.ToList(); + var resources = state.AvailableApiResources?.ToList(); if (resources == null) return state; foreach (var resource in resources) resource.IsSelected = act.IsSelected; return state with { - ApiResources = resources + AvailableApiResources = resources }; } diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourcesState.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourcesState.cs new file mode 100644 index 000000000..5737d4237 --- /dev/null +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/ApiResourcesState.cs @@ -0,0 +1,40 @@ +// Copyright (c) SimpleIdServer. All rights reserved. +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +using Fluxor; +using SimpleIdServer.IdServer.Domains; + +namespace SimpleIdServer.IdServer.Website.Stores.ApiResourceStore +{ + [FeatureState] + public record ApiResourcesState + { + public ApiResourcesState() { } + + public ApiResourcesState(bool isLoading, IEnumerable availableApiResources, IEnumerable activeApiResources) + { + AvailableApiResources = availableApiResources.Select(c => new SelectableApiResource(c)); + ActiveApiResources = activeApiResources.Select(c => new SelectableApiResource(c)); + AvailableCount = AvailableApiResources.Count(); + ActiveCount = ActiveApiResources.Count(); + IsLoading = isLoading; + } + + public IEnumerable? AvailableApiResources { get; set; } = null; + public IEnumerable? ActiveApiResources { get; set; } = null; + public int AvailableCount { get; set; } = 0; + public int ActiveCount { get; set; } = 0; + public bool IsLoading { get; set; } = false; + } + + public class SelectableApiResource + { + public SelectableApiResource(ApiResource apiResource) + { + Value = apiResource; + } + + public bool IsSelected { get; set; } = false; + public bool IsNew { get; set; } = false; + public ApiResource Value { get; set; } + } +} diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/SearchApiResourcesState.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/SearchApiResourcesState.cs deleted file mode 100644 index edcceca2e..000000000 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/ApiResourceStore/SearchApiResourcesState.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) SimpleIdServer. All rights reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. -using Fluxor; -using SimpleIdServer.IdServer.Domains; - -namespace SimpleIdServer.IdServer.Website.Stores.ApiResourceStore -{ - [FeatureState] - public record SearchApiResourcesState - { - public SearchApiResourcesState() { } - - public SearchApiResourcesState(bool isLoading, IEnumerable apiResources) - { - ApiResources = apiResources.Select(c => new SelectableApiResource(c)); - Count = apiResources.Count(); - IsLoading = isLoading; - } - - public IEnumerable? ApiResources { get; set; } = null; - public int Count { get; set; } = 0; - public bool IsLoading { get; set; } = false; - } - - public class SelectableApiResource - { - public SelectableApiResource(ApiResource apiResource) - { - Value = apiResource; - } - - public bool IsSelected { get; set; } = false; - public bool IsNew { get; set; } = false; - public ApiResource Value { get; set; } - } -} diff --git a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/Auditing/AuditingRecordEffects.cs b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/Auditing/AuditingRecordEffects.cs index 1288e4d31..487531db7 100644 --- a/src/IdServer/SimpleIdServer.IdServer.Website/Stores/Auditing/AuditingRecordEffects.cs +++ b/src/IdServer/SimpleIdServer.IdServer.Website/Stores/Auditing/AuditingRecordEffects.cs @@ -3,6 +3,7 @@ using Fluxor; using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; using Microsoft.Extensions.Options; +using SimpleIdServer.IdServer.Api.Auditing; using SimpleIdServer.IdServer.Domains; using SimpleIdServer.IdServer.DTOs; using SimpleIdServer.IdServer.Store; @@ -33,12 +34,13 @@ public async Task Handle(SearchAuditingRecordsAction action, IDispatcher dispatc { RequestUri = new Uri($"{baseUrl}/.search"), Method = HttpMethod.Post, - Content = new StringContent(JsonSerializer.Serialize(new SearchRequest + Content = new StringContent(JsonSerializer.Serialize(new SearchAuditingRequest { Filter = SanitizeExpression(action.Filter), OrderBy = SanitizeExpression(action.OrderBy), Skip = action.Skip, - Take = action.Take + Take = action.Take, + DisplayOnlyErrors = action.DisplayOnlyErrors }), Encoding.UTF8, "application/json") }; var httpResult = await httpClient.SendAsync(requestMessage); diff --git a/src/IdServer/SimpleIdServer.IdServer/UI/BaseAuthenticationMethodController.cs b/src/IdServer/SimpleIdServer.IdServer/UI/BaseAuthenticationMethodController.cs index 520aeaa4f..a62a3270c 100644 --- a/src/IdServer/SimpleIdServer.IdServer/UI/BaseAuthenticationMethodController.cs +++ b/src/IdServer/SimpleIdServer.IdServer/UI/BaseAuthenticationMethodController.cs @@ -127,6 +127,7 @@ public async virtual Task Index([FromRoute] string prefix, T view if (viewModel == null) return RedirectToAction("Index", "Errors", new { code = "invalid_request", ReturnUrl = $"{Request.Path}{Request.QueryString}", area = string.Empty }); var amrInfo = GetAmrInfo(); + EnrichViewModel(viewModel); await UpdateViewModel(viewModel); viewModel.CheckRequiredFields(ModelState); if (!ModelState.IsValid) return View(viewModel); diff --git a/src/IdServer/SimpleIdServer.IdServer/UI/HomeController.cs b/src/IdServer/SimpleIdServer.IdServer/UI/HomeController.cs index 1a33bc98f..e0952d514 100644 --- a/src/IdServer/SimpleIdServer.IdServer/UI/HomeController.cs +++ b/src/IdServer/SimpleIdServer.IdServer/UI/HomeController.cs @@ -335,7 +335,7 @@ async Task> GetConsents() var oauthClient = oauthClients.Single(c => c.ClientId == consent.ClientId); consents.Add(new ConsentViewModel( consent.Id, - oauthClient.ClientName, + string.IsNullOrWhiteSpace(oauthClient.ClientName) ? oauthClient.ClientId : oauthClient.ClientName, oauthClient.ClientUri, consent.Scopes.Select(s => s.Scope), consent.Claims,