Add envelope receiver access code request feature
Introduced a feature to allow envelope receivers to request an access code via email on the login page. - Added `OnInitializedAsync` in `LoginReceiverPage.razor` to trigger access code requests using `AuthService`. - Implemented `RequestEnvelopeReceiverAccessCodeAsync` in `AuthService.cs` to handle API calls for access code requests. - Added a new endpoint in `AuthController` to process access code requests, including validation, history recording, and email dispatching. - Registered `IEnvelopeMailService` and `AddDispatcher` in `Program.cs` to support email dispatch and database operations. - Refactored `AuthController` constructor for readability and added necessary `using` directives. - Improved logging and error handling for better traceability and robustness. These changes ensure a seamless and secure process for envelope receivers to request access codes, enhancing the user experience.
This commit is contained in:
@@ -144,6 +144,14 @@
|
||||
bool IsLoading;
|
||||
EnvelopeLoginResult? LoginResult;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(EnvelopeKey))
|
||||
return;
|
||||
|
||||
_ = await AuthService.RequestEnvelopeReceiverAccessCodeAsync(EnvelopeKey);
|
||||
}
|
||||
|
||||
async Task OnKeyDownAsync(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Enter")
|
||||
|
||||
@@ -33,6 +33,20 @@ public class AuthService(IHttpClientFactory httpClientFactory)
|
||||
return response.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers access code e-mail request flow for the receiver login page.
|
||||
/// Calls POST /api/Auth/envelope-receiver/{key}/request-access-code.
|
||||
/// </summary>
|
||||
public async Task<bool> RequestEnvelopeReceiverAccessCodeAsync(string envelopeKey, CancellationToken cancel = default)
|
||||
{
|
||||
using var http = CreateDefaultClient();
|
||||
var response = await http.PostAsync(
|
||||
$"/api/Auth/envelope-receiver/{Uri.EscapeDataString(envelopeKey)}/request-access-code",
|
||||
null,
|
||||
cancel);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Submits the access code for the given envelope key.
|
||||
/// Calls POST /api/Auth/envelope-receiver/{key} with multipart/form-data.
|
||||
|
||||
Reference in New Issue
Block a user