diff --git a/EnvelopeGenerator.ReceiverUI/Pages/LoginSender.razor b/EnvelopeGenerator.ReceiverUI/Pages/LoginSender.razor new file mode 100644 index 00000000..b1536d0d --- /dev/null +++ b/EnvelopeGenerator.ReceiverUI/Pages/LoginSender.razor @@ -0,0 +1,172 @@ +@page "/login" +@using EnvelopeGenerator.ReceiverUI.Services +@inject AuthService AuthService +@inject NavigationManager Navigation + + + +
+
+ +
+
+ + + + +
+
Sender Anmeldung
+

Sicherer Zugang zum Sender-Dashboard

+
+ +
+ +

+ Bitte melden Sie sich mit Ihren Zugangsdaten an, um auf das Sender-Dashboard zuzugreifen. +

+ + @if (LoginResult == SenderLoginResult.InvalidCredentials) { + + } else if (LoginResult == SenderLoginResult.Error) { + + } + +
+ +
+ + + + + + +
+
+ +
+ +
+ + + + + + + +
+
+ + + +
+ + + +
+
+ +@code { + string Username = string.Empty; + string Password = string.Empty; + bool ShowPassword; + bool IsLoading; + SenderLoginResult? LoginResult; + + async Task OnKeyDownAsync(Microsoft.AspNetCore.Components.Web.KeyboardEventArgs e) { + if (e.Key == "Enter") + await SubmitAsync(); + } + + async Task SubmitAsync() { + if (string.IsNullOrWhiteSpace(Username) || string.IsNullOrWhiteSpace(Password) || IsLoading) return; + + IsLoading = true; + LoginResult = null; + await InvokeAsync(StateHasChanged); + + var result = await AuthService.LoginSenderAsync(Username.Trim(), Password.Trim()); + + if (result == SenderLoginResult.Success) { + Navigation.NavigateTo("/", forceLoad: true); + return; + } + + LoginResult = result; + IsLoading = false; + await InvokeAsync(StateHasChanged); + } +} +