From 28b8bebe610202c1060d605b411ec17f3435676a Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 8 Jun 2026 00:37:30 +0200 Subject: [PATCH] Add logout functionality to EnvelopeViewer Added dependency injection for `AuthService` to enable authentication-related operations. Introduced a logout button in the UI, conditionally displayed when `EnvelopeKey` is valid, with a spinner and SVG icon for better UX. Implemented the `LogoutAsync` method to handle the logout process, ensuring no concurrent logouts and redirecting the user to the login page. Added `_isLoggingOut` to manage logout state. Updated `OnInitializedAsync` for better error handling when `EnvelopeKey` is missing. --- .../Pages/EnvelopeViewer.razor | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor b/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor index 4e11446d..422f4fc1 100644 --- a/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor +++ b/EnvelopeGenerator.ReceiverUI/Pages/EnvelopeViewer.razor @@ -12,6 +12,7 @@ @inject IOptions PdfViewerOptions @inject IJSRuntime JSRuntime @inject SignatureService SignatureService +@inject EnvelopeGenerator.ReceiverUI.Services.AuthService AuthService @implements IAsyncDisposable @@ -35,6 +36,18 @@
ID: @EnvelopeKey
+ @if (!string.IsNullOrWhiteSpace(EnvelopeKey)) { + + } @@ -377,6 +390,7 @@ int _currentPage = 1; int _totalPages = 0; int _currentZoom = 150; bool _showThumbnails = true; +bool _isLoggingOut = false; DotNetObjectReference? _dotNetRef; IReadOnlyList _signatures = []; @@ -406,6 +420,14 @@ int _resizeStartWidth = 0; const int MinThumbnailWidth = 150; const int MaxThumbnailWidth = 400; + async Task LogoutAsync() { + if (string.IsNullOrWhiteSpace(EnvelopeKey) || _isLoggingOut) return; + _isLoggingOut = true; + await InvokeAsync(StateHasChanged); + await AuthService.LogoutEnvelopeReceiverAsync(EnvelopeKey); + Navigation.NavigateTo($"/login/{Uri.EscapeDataString(EnvelopeKey)}", forceLoad: true); + } + protected override async Task OnInitializedAsync() { if (string.IsNullOrWhiteSpace(EnvelopeKey)) { _errorMessage = "Envelope-Schlüssel fehlt.";