Add logout functionality for envelope sessions
Introduced a "Logout" button in `ReportViewer.razor` that is displayed when an `EnvelopeKey` is present. The button includes a spinner to indicate progress during the logout process. Added the `LogoutAsync` method in `ReportViewer.razor` to handle the logout operation, preventing multiple attempts and navigating the user to the login page upon success. Implemented `LogoutEnvelopeReceiverAsync` in `AuthService` to send a POST request to remove the per-envelope receiver cookie. This ensures proper backend handling of the logout process. Improved user experience by providing a responsive and clear logout mechanism for envelope-based sessions.
This commit is contained in:
@@ -42,4 +42,16 @@ public class AuthService(HttpClient http, IOptions<ApiOptions> apiOptions)
|
||||
_ => EnvelopeLoginResult.Error
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the per-envelope receiver cookie for the given envelope key.
|
||||
/// Calls POST /api/auth/logout/envelope/{envelopeKey}.
|
||||
/// </summary>
|
||||
public async Task<bool> LogoutEnvelopeReceiverAsync(string envelopeKey, CancellationToken cancel = default)
|
||||
{
|
||||
var response = await http.PostAsync(
|
||||
$"{_api.BaseUrl}/api/auth/logout/envelope/{Uri.EscapeDataString(envelopeKey)}",
|
||||
null, cancel);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user