Refactor sender page and auth service logic
- Added project reference to `EnvelopeGenerator.Application` in the client project. - Updated imports and injected services in `EnvelopeSenderPage.razor`. - Improved null handling for `EnvelopeReceivers` and updated email display logic. - Replaced `CheckSenderAsync` with `CheckSenderAccessAsync` for authorization. - Refactored `GetStatusInfo` to use `EnvelopeStatus` enum directly. - Added `CheckSenderAccessAsync` and `LogoutSenderAsync` methods in `AuthService`. - Simplified `Logout` logic in `AuthController` to remove redundant checks.
This commit is contained in:
@@ -22,6 +22,17 @@ public class AuthService(IHttpClientFactory httpClientFactory)
|
||||
return response.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the current user holds a valid receiver token for the given envelope key.
|
||||
/// Calls GET /api/auth/check/envelope/{envelopeKey}.
|
||||
/// </summary>
|
||||
public async Task<bool> CheckSenderAccessAsync(CancellationToken cancel = default)
|
||||
{
|
||||
using var http = CreateDefaultClient();
|
||||
var response = await http.GetAsync($"/api/auth/check", cancel);
|
||||
return response.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Submits the access code for the given envelope key.
|
||||
/// Calls POST /api/Auth/envelope-receiver/{key} with multipart/form-data.
|
||||
@@ -61,6 +72,19 @@ public class AuthService(IHttpClientFactory httpClientFactory)
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the per-envelope receiver cookie for the given envelope key.
|
||||
/// Calls POST /api/auth/logout/envelope/{envelopeKey}.
|
||||
/// </summary>
|
||||
public async Task<bool> LogoutSenderAsync(CancellationToken cancel = default)
|
||||
{
|
||||
using var http = CreateDefaultClient();
|
||||
var response = await http.PostAsync(
|
||||
$"/api/auth/logout",
|
||||
null, cancel);
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticates a sender user with username and password.
|
||||
/// Calls POST /api/auth?cookie=true with JSON body.
|
||||
|
||||
Reference in New Issue
Block a user