Error message on invalid credentials

This commit is contained in:
Andre Beging
2022-05-30 11:05:19 +02:00
parent a9ce2810c8
commit 607fab1d04
2 changed files with 12 additions and 7 deletions

View File

@@ -3,6 +3,8 @@
@using FoodsharingSiegen.Shared.Helper
@layout LoginLayout
@inherits FoodsharingSiegen.Server.BaseClasses.FsBase
@inject AuthService AuthService
@inject NavigationManager NavigationManager
@@ -11,7 +13,7 @@
<div class="card-header">FS Siegen</div>
<div class="card-body">
<Validation Validator="ValidationHelper.ValidateMail" @bind-Status="@IsValidMail">
<TextEdit @bind-Text="Mailaddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
<TextEdit @bind-Text="MailAddress" Role="TextRole.Email" Placeholder="E-Mail" Class="mt-0" KeyUp="TextEdit_KeyUp"></TextEdit>
</Validation>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">

View File

@@ -1,4 +1,3 @@
using System.Text.RegularExpressions;
using Blazorise;
using Microsoft.AspNetCore.Components.Web;
@@ -26,9 +25,9 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Properties
/// <summary>
/// Gets or sets the value of the mailaddress (ab)
/// Gets or sets the value of the mail-address (ab)
/// </summary>
private string? Mailaddress { get; set; }
private string? MailAddress { get; set; }
/// <summary>
/// Gets or sets the value of the password (ab)
@@ -46,18 +45,22 @@ namespace FoodsharingSiegen.Server.Pages
{
//Todo Eingaben Validieren [04.04.22 - Andre Beging]
if (string.IsNullOrWhiteSpace(Mailaddress) || string.IsNullOrWhiteSpace(Password))
if (string.IsNullOrWhiteSpace(MailAddress) || string.IsNullOrWhiteSpace(Password))
{
Mailaddress = string.Empty;
MailAddress = string.Empty;
Password = string.Empty;
return;
}
var loginR = await AuthService.Login(Mailaddress, Password);
var loginR = await AuthService.Login(MailAddress, Password);
if (loginR.Success)
{
NavigationManager.NavigateTo("/", true);
}
else
{
await Notification?.Error(loginR.ErrorMessage)!;
}
}
#endregion