19 changed files with 308 additions and 68 deletions
@ -0,0 +1,10 @@ |
|||||
|
using Microsoft.AspNetCore.Components; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Client.Elements |
||||
|
{ |
||||
|
public partial class Footer |
||||
|
{ |
||||
|
[Parameter] |
||||
|
public EventCallback OnClickCallback { get; set; } |
||||
|
} |
||||
|
} |
@ -0,0 +1,42 @@ |
|||||
|
ul { |
||||
|
flex-direction: column; |
||||
|
background: #3f7672; |
||||
|
top: 1rem; |
||||
|
border-radius: 10px; |
||||
|
list-style-type: none; |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
position: absolute; |
||||
|
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); |
||||
|
z-index: 1; |
||||
|
} |
||||
|
|
||||
|
li { |
||||
|
padding: 8px; |
||||
|
border-bottom: 1px solid #ffffff; /* Border between items */ |
||||
|
} |
||||
|
|
||||
|
li:last-child { |
||||
|
border-bottom: none; /* Remove border from the last item */ |
||||
|
} |
||||
|
|
||||
|
a { |
||||
|
color: #ffffff; /* Dropdown item text color */ |
||||
|
text-decoration: none; |
||||
|
display: block; |
||||
|
padding: 8px; |
||||
|
cursor:pointer; |
||||
|
} |
||||
|
|
||||
|
a:hover { |
||||
|
color:#003445; /* Hover background color */ |
||||
|
} |
||||
|
|
||||
|
/* Show the dropdown when the container is clicked */ |
||||
|
.show ul { |
||||
|
display: block; |
||||
|
} |
||||
|
|
||||
|
.hidden { |
||||
|
display: none; |
||||
|
} |
@ -0,0 +1,142 @@ |
|||||
|
using Biskilog_Accounting.Shared.ClientContractModels; |
||||
|
using Microsoft.AspNetCore.Components.Web; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using static System.Net.WebRequestMethods; |
||||
|
using System.Net.Http.Headers; |
||||
|
using System.Net.Http.Json; |
||||
|
|
||||
|
namespace Biskilog_Accounting.Client.Pages.Auth.Components |
||||
|
{ |
||||
|
public partial class UsernameTab |
||||
|
{ |
||||
|
private string m_email, m_password; |
||||
|
private bool m_remember { get; set; } |
||||
|
protected bool IsVisible { get; set; } |
||||
|
private string m_usernameErrorClass = "hidden"; |
||||
|
private string m_passwordErrorClass = "hidden"; |
||||
|
//NotificationMessage notificationMessage = new NotificationMessage();
|
||||
|
private Userauth authenticatedUser; |
||||
|
/// <summary>
|
||||
|
/// Handles the click or press event of the enter key
|
||||
|
/// </summary>
|
||||
|
/// <param name="e"></param>
|
||||
|
public async void Enter(KeyboardEventArgs e) |
||||
|
{ |
||||
|
if (e.Code == "Enter" || e.Code == "NumpadEnter") |
||||
|
{ |
||||
|
FieldValidation(); |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(m_email) && !string.IsNullOrEmpty(m_password)) |
||||
|
{ |
||||
|
await Authenticate(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Validates the username and password input fields and shows the appropriate indicators
|
||||
|
/// </summary>
|
||||
|
private void FieldValidation() |
||||
|
{ |
||||
|
if (string.IsNullOrEmpty(m_email)) |
||||
|
{ |
||||
|
m_usernameErrorClass = ""; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
m_usernameErrorClass = "hidden"; |
||||
|
} |
||||
|
if (string.IsNullOrEmpty(m_password)) |
||||
|
{ |
||||
|
m_passwordErrorClass = ""; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
m_passwordErrorClass = "hidden"; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Authenticates the user and determines the type of page layout to show
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
async Task Authenticate() |
||||
|
{ |
||||
|
FieldValidation(); |
||||
|
|
||||
|
ShowSpinner(); |
||||
|
try |
||||
|
{ |
||||
|
authenticatedUser = new Userauth |
||||
|
{ |
||||
|
UserId = 0, |
||||
|
Username = m_email, |
||||
|
Email = m_email, |
||||
|
Passsword = m_password |
||||
|
}; |
||||
|
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); |
||||
|
|
||||
|
var authHeader = new AuthenticationHeaderValue("Bearer", token); |
||||
|
m_http.DefaultRequestHeaders.Authorization = authHeader; |
||||
|
|
||||
|
m_navigationManager.NavigateTo("/"); |
||||
|
} |
||||
|
else if (responseMain.StatusCode == System.Net.HttpStatusCode.BadRequest) |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Console.WriteLine(ex.ToString()); |
||||
|
} |
||||
|
HideSpinner(); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Shows the loading spinner
|
||||
|
/// </summary>
|
||||
|
public void ShowSpinner() |
||||
|
{ |
||||
|
IsVisible = true; |
||||
|
StateHasChanged(); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Hides the loading spinner
|
||||
|
/// </summary>
|
||||
|
public void HideSpinner() |
||||
|
{ |
||||
|
IsVisible = false; |
||||
|
StateHasChanged(); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Shows a notification message
|
||||
|
/// </summary>
|
||||
|
/// <param name="message"></param>
|
||||
|
/// <returns></returns>
|
||||
|
//async Task ShowNotification(NotificationMessage message)
|
||||
|
//{
|
||||
|
// notificationService.Notify(message);
|
||||
|
|
||||
|
// await InvokeAsync(() => { StateHasChanged(); });
|
||||
|
//}
|
||||
|
/// <summary>
|
||||
|
/// Sets the username value
|
||||
|
/// </summary>
|
||||
|
/// <param name="value"></param>
|
||||
|
void usernameInput(string value) |
||||
|
{ |
||||
|
m_email = value; |
||||
|
StateHasChanged(); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Sets the password value
|
||||
|
/// </summary>
|
||||
|
/// <param name="value"></param>
|
||||
|
void passwordInput(string value) |
||||
|
{ |
||||
|
m_password = value; |
||||
|
StateHasChanged(); |
||||
|
} |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue