diff --git a/FoodsharingSiegen.Server/Pages/Login.razor b/FoodsharingSiegen.Server/Pages/Login.razor index 36d720c..97f7147 100644 --- a/FoodsharingSiegen.Server/Pages/Login.razor +++ b/FoodsharingSiegen.Server/Pages/Login.razor @@ -1,29 +1,26 @@ @page "/login" -@using FoodsharingSiegen.Server.Service @using FoodsharingSiegen.Server.Auth @layout LoginLayout @inject AuthService AuthService @inject NavigationManager NavigationManager -@code -{ - private string? Mailaddress { get; set; } +
+
+
FS Siegen
+
+ + + - private string? Password { get; set; } + + + - private async Task PerformLogin() - { - //Todo Eingaben Validieren [04.04.22 - Andre Beging] - - var loginR = await AuthService.Login(Mailaddress, Password); - if (loginR.Success) - { - NavigationManager.NavigateTo("/", true); - } - } -} +
+ +
- - - \ No newline at end of file +
+
+
\ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/Login.razor.cs b/FoodsharingSiegen.Server/Pages/Login.razor.cs new file mode 100644 index 0000000..01633f8 --- /dev/null +++ b/FoodsharingSiegen.Server/Pages/Login.razor.cs @@ -0,0 +1,123 @@ +using System.Text.RegularExpressions; +using Blazorise; +using Microsoft.AspNetCore.Components.Web; + +namespace FoodsharingSiegen.Server.Pages +{ + /// + /// The login class (a. beging, 11.04.2022) + /// + public partial class Login + { + #region Public Properties + + /// + /// Gets or sets the value of the is valid mail (ab) + /// + public ValidationStatus IsValidMail { get; set; } + + /// + /// Gets or sets the value of the is valid password (ab) + /// + public ValidationStatus IsValidPassword { get; set; } + + #endregion + + #region Private Properties + + /// + /// Gets or sets the value of the mailaddress (ab) + /// + private string? Mailaddress { get; set; } + + /// + /// Gets or sets the value of the password (ab) + /// + private string? Password { get; set; } + + #endregion + + #region Private Method PerformLogin + + /// + /// Performs the login (a. beging, 11.04.2022) + /// + private async Task PerformLogin() + { + //Todo Eingaben Validieren [04.04.22 - Andre Beging] + + if (string.IsNullOrWhiteSpace(Mailaddress) || string.IsNullOrWhiteSpace(Password)) + { + Mailaddress = string.Empty; + Password = string.Empty; + return; + } + + var loginR = await AuthService.Login(Mailaddress, Password); + if (loginR.Success) + { + NavigationManager.NavigateTo("/", true); + } + } + + #endregion + + #region Private Method TextEdit_KeyUp + + /// + /// Texts the edit key up using the specified arg (a. beging, 11.04.2022) + /// + /// The arg + private async Task TextEdit_KeyUp(KeyboardEventArgs arg) + { + if (arg.Key == "Enter") await PerformLogin(); + } + + #endregion + + #region Private Method ValidateMail + + /// + /// Validates the mail using the specified args (a. beging, 11.04.2022) + /// + /// The args + private void ValidateMail(ValidatorEventArgs args) + { + var email = Convert.ToString(args.Value); + + if (string.IsNullOrWhiteSpace(email)) + { + args.Status = ValidationStatus.None; + return; + } + + var isMatch = Regex.IsMatch(email, "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", RegexOptions.IgnoreCase); + + args.Status = isMatch ? ValidationStatus.Success : ValidationStatus.Error; + } + + #endregion + + #region Private Method ValidatePassword + + /// + /// Validates the password using the specified args (a. beging, 11.04.2022) + /// + /// The args + private void ValidatePassword(ValidatorEventArgs args) + { + var password = Convert.ToString(args.Value); + if (string.IsNullOrWhiteSpace(password)) + { + args.Status = ValidationStatus.None; + return; + } + + var isValid = password.Length > 3; + + args.Status = isValid ? ValidationStatus.Success : ValidationStatus.Error; + } + + #endregion + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Shared/LoginLayout.razor b/FoodsharingSiegen.Server/Shared/LoginLayout.razor index ed59518..da0cbc8 100644 --- a/FoodsharingSiegen.Server/Shared/LoginLayout.razor +++ b/FoodsharingSiegen.Server/Shared/LoginLayout.razor @@ -4,8 +4,6 @@
-
- @Body -
+ @Body
\ No newline at end of file diff --git a/FoodsharingSiegen.Server/app.db-shm b/FoodsharingSiegen.Server/app.db-shm deleted file mode 100644 index 6cc18ac..0000000 Binary files a/FoodsharingSiegen.Server/app.db-shm and /dev/null differ diff --git a/FoodsharingSiegen.Server/app.db-wal b/FoodsharingSiegen.Server/app.db-wal deleted file mode 100644 index e5adf8a..0000000 Binary files a/FoodsharingSiegen.Server/app.db-wal and /dev/null differ