diff --git a/Client/Pages/Auth/Login.razor b/Client/Pages/Auth/Login.razor index 96965ec..0a7aa13 100644 --- a/Client/Pages/Auth/Login.razor +++ b/Client/Pages/Auth/Login.razor @@ -81,19 +81,29 @@

Please login to your account

- +
- + @if (showUsernameError) + { +

Enter valid Uaername

+ + } +
- + @if (showPasswordError) + { +

Enter valid Password

+ + } +
diff --git a/Client/Pages/Auth/Login.razor.cs b/Client/Pages/Auth/Login.razor.cs index 0918a07..2c512f9 100644 --- a/Client/Pages/Auth/Login.razor.cs +++ b/Client/Pages/Auth/Login.razor.cs @@ -10,8 +10,10 @@ namespace Biskilog_Accounting.Client.Pages.Auth public partial class Login { private string m_email, m_password; + private bool showUsernameError, showPasswordError; private bool m_remember { get; set; } protected bool IsVisible { get; set; } + //NotificationMessage notificationMessage = new NotificationMessage(); private Userauth authenticatedUser; /// @@ -45,14 +47,23 @@ namespace Biskilog_Accounting.Client.Pages.Auth var responseMain = await m_http.PostAsJsonAsync("api/authentication/type-a", authenticatedUser); if (responseMain.IsSuccessStatusCode) { - string token = await responseMain.Content.ReadAsStringAsync(); - await m_tokenService.SetToken(token, m_remember); + showUsernameError = string.IsNullOrEmpty(m_email); + showPasswordError = string.IsNullOrEmpty(m_password); + + if(!showUsernameError && !showPasswordError) + { + string token = await responseMain.Content.ReadAsStringAsync(); + await m_tokenService.SetToken(token, m_remember); + + var authHeader = new AuthenticationHeaderValue("Bearer", token); + m_http.DefaultRequestHeaders.Authorization = authHeader; - var authHeader = new AuthenticationHeaderValue("Bearer", token); - m_http.DefaultRequestHeaders.Authorization = authHeader; + m_navigationManager.NavigateTo("/"); + } - m_navigationManager.NavigateTo("/"); } + + else if (responseMain.StatusCode == System.Net.HttpStatusCode.BadRequest) { } @@ -108,5 +119,7 @@ namespace Biskilog_Accounting.Client.Pages.Auth m_password = value; StateHasChanged(); } + + } } \ No newline at end of file