diff --git a/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor b/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor new file mode 100644 index 0000000..6000aa0 --- /dev/null +++ b/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor @@ -0,0 +1,52 @@ +@page "/oauth2/clients/{ClientId}/edit" +@using Ory.Hydra.Client.Model +@attribute [StreamRendering] +@attribute [RenderModeInteractiveServer] +@inject ICustomTranslator Translator +@inject ILogger Logger +@inject NavigationManager Navigation + +Edit Client + +

Edit Client

+@if (_isLoading) +{ + // is loading +

Loading data...

+} +else +{ +
+
+ +
+
+ +
+
+ @_errorMessage +
+
+
+ + Cancel + + +
+
+
+} \ No newline at end of file diff --git a/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor.cs b/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor.cs new file mode 100644 index 0000000..717b431 --- /dev/null +++ b/OryAdmin/Components/Pages/OAuth2/Clients/Edit.razor.cs @@ -0,0 +1,46 @@ +using Microsoft.AspNetCore.Components; +using Ory.Hydra.Client.Model; +using Ory.Kratos.Client.Client; +using OryAdmin.Services; + +namespace OryAdmin.Components.Pages.OAuth2.Clients; + +public partial class Edit +{ + private HydraOAuth2Client? _client; + private string? _errorMessage; + private bool _isLoading = true; + + [Parameter] + public required string ClientId { get; set; } + + private readonly List _patches = new(); + + [Inject] private ApiService ApiService { get; set; } = default!; + + protected override async Task OnInitializedAsync() + { + _client = await ApiService.HydraOAuth2.GetOAuth2ClientAsync(ClientId); + _isLoading = false; + } + + private async Task SubmitForm() + { + try + { + _ = await ApiService.HydraOAuth2.PatchOAuth2ClientAsync(ClientId, _patches); + } + catch (ApiException exception) + { + _errorMessage = exception.Message; + return; + } + + Navigation.NavigateTo("oauth2/clients"); + } + + private void AddPatch(HydraJsonPatch patch) + { + _patches.Add(patch); + } +} \ No newline at end of file diff --git a/OryAdmin/Components/Pages/OAuth2/Clients/View.razor b/OryAdmin/Components/Pages/OAuth2/Clients/View.razor index d655004..5912b44 100644 --- a/OryAdmin/Components/Pages/OAuth2/Clients/View.razor +++ b/OryAdmin/Components/Pages/OAuth2/Clients/View.razor @@ -24,13 +24,17 @@ else @(_client!.ClientId) - Name + Client Name @(string.IsNullOrWhiteSpace(_client.ClientName) ? "-" : _client.ClientName) - Secret + Client Secret @(string.IsNullOrWhiteSpace(_client.ClientSecret) ? "-" : _client.ClientSecret) + + Client Secret Expires At + @(_client.ClientSecretExpiresAt == 0 ? "never" : _client.ClientSecretExpiresAt) + Scope @(string.IsNullOrWhiteSpace(_client.Scope) ? "-" : _client.Scope.Replace(" ", ", ")) @@ -302,10 +306,6 @@ else Backchannel Logout Session Required @(_client.BackchannelLogoutSessionRequired ? "Yes" : "No") - - Client Secret Expires At - @(_client.ClientSecretExpiresAt == 0 ? "never" : _client.ClientSecretExpiresAt) - Frontchannel Logout Session Required @(_client.FrontchannelLogoutSessionRequired ? "Yes" : "No")