From 0ca7c01bc4a6c5ab50ac80f9a8e5d5c5db442f45 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 1 Jun 2025 08:04:30 +0200 Subject: Register works, part of login and auth middleware --- testFrontend/SafeNSound.Frontend/Pages/Auth.razor | 57 +++++++++++++++++++---- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'testFrontend/SafeNSound.Frontend/Pages') diff --git a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor index 533fc01..6c28bf1 100644 --- a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor +++ b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor @@ -11,8 +11,10 @@
Type (R): (one of user|monitor|admin)
-Login -Register +Randomise +Register +Login +Delete

@if (Exception != null) { @@ -34,14 +36,22 @@ } @code { - private string Username { get; set; } = ""; - private string Email { get; set; } = ""; - private string Password { get; set; } = ""; + private string Username { get; set; } = String.Empty; + private string Email { get; set; } = String.Empty; + private string Password { get; set; } = String.Empty; private string UserType { get; set; } = ""; private Exception? Exception { get; set; } private object? Result { get; set; } + private async Task Randomise() { + Username = Guid.NewGuid().ToString(); + Email = Guid.NewGuid().ToString() + "@example.com"; + Password = Guid.NewGuid().ToString(); + UserType = Random.Shared.GetItems(["user", "monitor", "admin"], 1)[0]; + StateHasChanged(); + } + private async Task Register() { Result = null; Exception = null; @@ -56,13 +66,42 @@ catch (Exception ex) { Exception = ex; } - finally { - StateHasChanged(); + + StateHasChanged(); + } + + private async Task Login() { + Result = null; + Exception = null; + try { + Result = await Authentication.Login(new() { + Username = Username, + Password = Password, + Email = Email + }); + } + catch (Exception ex) { + Exception = ex; } + + StateHasChanged(); } - private Task Login() { - throw new NotImplementedException(); + private async Task Delete() { + Result = null; + Exception = null; + try { + Result = await Authentication.Delete(new() { + Username = Username, + Password = Password, + Email = Email + }); + } + catch (Exception ex) { + Exception = ex; + } + + StateHasChanged(); } } \ No newline at end of file -- cgit 1.5.1