From fc6fc6ce7fb7742952f33613b29b3f2cfa9dedfb Mon Sep 17 00:00:00 2001 From: barhen Date: Sun, 17 Dec 2023 10:49:45 -0500 Subject: [PATCH] Login cleanup --- Client/Pages/Auth/Login.razor.cs | 112 ------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 Client/Pages/Auth/Login.razor.cs diff --git a/Client/Pages/Auth/Login.razor.cs b/Client/Pages/Auth/Login.razor.cs deleted file mode 100644 index 0918a07..0000000 --- a/Client/Pages/Auth/Login.razor.cs +++ /dev/null @@ -1,112 +0,0 @@ -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components; -using System.Net.Http.Headers; -using Biskilog_Accounting.Shared.ClientContractModels; -using Biskilog_Accounting.Shared.Interfaces; -using System.Net.Http.Json; - -namespace Biskilog_Accounting.Client.Pages.Auth -{ - public partial class Login - { - private string m_email, m_password; - private bool m_remember { get; set; } - protected bool IsVisible { get; set; } - //NotificationMessage notificationMessage = new NotificationMessage(); - private Userauth authenticatedUser; - /// - /// Handles the click or press event of the enter key - /// - /// - public async void Enter(KeyboardEventArgs e) - { - if (e.Code == "Enter" || e.Code == "NumpadEnter") - { - await pagaAuth(); - } - } - /// - /// Authenticates the user and determines the type of page layout to show - /// - /// - async Task pagaAuth() - { - - 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(); - } - /// - /// Shows the loading spinner - /// - public void ShowSpinner() - { - IsVisible = true; - StateHasChanged(); - } - /// - /// Hides the loading spinner - /// - public void HideSpinner() - { - IsVisible = false; - StateHasChanged(); - } - /// - /// Shows a notification message - /// - /// - /// - //async Task ShowNotification(NotificationMessage message) - //{ - // notificationService.Notify(message); - - // await InvokeAsync(() => { StateHasChanged(); }); - //} - /// - /// Sets the username value - /// - /// - void usernameInput(string value) - { - m_email = value; - StateHasChanged(); - } - /// - /// Sets the password value - /// - /// - void passwordInput(string value) - { - m_password = value; - StateHasChanged(); - } - } -} \ No newline at end of file