Introduced a new login page (`Login.razor`) to handle user authentication via access codes. Implemented `AuthService` to validate access codes through an API. Updated `ReportViewer.razor` to check user access and redirect unauthorized users to the login page. Modified `Program.cs` to register `AuthService` for dependency injection. Enhanced document fetching in `ReportViewer.razor` to ensure secure access control.
72 lines
2.5 KiB
Plaintext
72 lines
2.5 KiB
Plaintext
@page "/login/{EnvelopeKey}"
|
|
@using EnvelopeGenerator.ReceiverUI.Options
|
|
@using Microsoft.Extensions.Options
|
|
|
|
<div class="login-page-wrapper d-flex align-items-center justify-content-center min-vh-100 bg-light">
|
|
<div class="card shadow-sm" style="max-width: 420px; width: 100%;">
|
|
<div class="card-body p-4">
|
|
|
|
<h4 class="card-title mb-1">Zugang zum Dokument</h4>
|
|
<p class="text-muted mb-4" style="font-size: 0.9rem;">
|
|
Bitte geben Sie den Zugangscode ein, den Sie per E-Mail erhalten haben, um das Dokument zu öffnen.
|
|
</p>
|
|
|
|
@if (!string.IsNullOrWhiteSpace(ErrorMessage)) {
|
|
<div class="alert alert-danger py-2">@ErrorMessage</div>
|
|
}
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label" for="login-access-code">Zugangscode</label>
|
|
<input id="login-access-code"
|
|
type="password"
|
|
class="form-control"
|
|
placeholder="Zugangscode eingeben"
|
|
@bind="AccessCode"
|
|
@bind:event="oninput"
|
|
@onkeydown="OnKeyDownAsync"
|
|
disabled="@IsLoading" />
|
|
</div>
|
|
|
|
<button class="btn btn-primary w-100"
|
|
@onclick="SubmitAsync"
|
|
disabled="@(IsLoading || string.IsNullOrWhiteSpace(AccessCode))">
|
|
@if (IsLoading) {
|
|
<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>
|
|
<span>Überprüfen …</span>
|
|
} else {
|
|
<span>Weiter</span>
|
|
}
|
|
</button>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public string EnvelopeKey { get; set; } = string.Empty;
|
|
|
|
string AccessCode = string.Empty;
|
|
string? ErrorMessage;
|
|
bool IsLoading;
|
|
|
|
async Task OnKeyDownAsync(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e) {
|
|
if (e.Key == "Enter")
|
|
await SubmitAsync();
|
|
}
|
|
|
|
async Task SubmitAsync() {
|
|
if (string.IsNullOrWhiteSpace(AccessCode)) return;
|
|
|
|
IsLoading = true;
|
|
ErrorMessage = null;
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
// TODO: API entegrasyonu buraya eklenecek
|
|
await Task.Delay(500); // placeholder
|
|
|
|
IsLoading = false;
|
|
ErrorMessage = "Der eingegebene Zugangscode ist ungültig. Bitte versuchen Sie es erneut.";
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
}
|