Browse Source

Added latest validation update

BISKI2023-18
parent
commit
489d1f46c0
  1. 12
      Client/Pages/Auth/Login.razor
  2. 20
      Client/Pages/Auth/Login.razor.cs

12
Client/Pages/Auth/Login.razor

@ -87,21 +87,19 @@
<input type="email" id="form2Example11" class="form-control"
placeholder="Phone number or email address" @oninput="@(args => usernameInput(args.Value.ToString()))" @onkeydown="@Enter" />
<label class="form-label" for="form2Example11">Username</label>
@if (showUsernameError)
{
<p class="text-danger">Enter valid Uaername</p>
@if (!validStatus)
{
<p class="text-danger">@errormeaasge("invalid")</p>
}
</div>
<div class="form-outline mb-4">
<input type="password" id="form2Example22" class="form-control" @oninput="@(args => passwordInput(args.Value.ToString()))" @onkeydown="@Enter" />
<label class="form-label" for="form2Example22">Password</label>
@if (showPasswordError)
@if (!validStatus)
{
<p class="text-danger">Enter valid Password</p>
<p class="text-danger">@errormeaasge("invalid")</p>
}
</div>

20
Client/Pages/Auth/Login.razor.cs

@ -13,6 +13,7 @@ namespace Biskilog_Accounting.Client.Pages.Auth
private bool showUsernameError, showPasswordError;
private bool m_remember { get; set; }
protected bool IsVisible { get; set; }
public bool validStatus = false;
//NotificationMessage notificationMessage = new NotificationMessage();
private Userauth authenticatedUser;
@ -47,11 +48,9 @@ namespace Biskilog_Accounting.Client.Pages.Auth
var responseMain = await m_http.PostAsJsonAsync("api/authentication/type-a", authenticatedUser);
if (responseMain.IsSuccessStatusCode)
{
showUsernameError = string.IsNullOrEmpty(m_email);
showPasswordError = string.IsNullOrEmpty(m_password);
if(!showUsernameError && !showPasswordError)
{
validStatus = true;
string token = await responseMain.Content.ReadAsStringAsync();
await m_tokenService.SetToken(token, m_remember);
@ -59,7 +58,7 @@ namespace Biskilog_Accounting.Client.Pages.Auth
m_http.DefaultRequestHeaders.Authorization = authHeader;
m_navigationManager.NavigateTo("/");
}
}
@ -120,6 +119,17 @@ namespace Biskilog_Accounting.Client.Pages.Auth
StateHasChanged();
}
public string errormeaasge(string message)
{
showPasswordError = string.IsNullOrEmpty(m_email);
showUsernameError = string.IsNullOrEmpty(m_password);
if (showUsernameError && showPasswordError)
{
message = "";
}
return message;
}
}
}
Loading…
Cancel
Save