From a22c00fcefa10a99505c05393106fb3a655de243 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 1 Jun 2025 04:40:09 +0200 Subject: Add register with validation --- testFrontend/SafeNSound.Frontend/Pages/Auth.razor | 68 ++++++++++++++++++++++ .../SafeNSound.Frontend/Pages/Counter.razor | 19 ------ 2 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 testFrontend/SafeNSound.Frontend/Pages/Auth.razor delete mode 100644 testFrontend/SafeNSound.Frontend/Pages/Counter.razor (limited to 'testFrontend/SafeNSound.Frontend/Pages') diff --git a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor new file mode 100644 index 0000000..533fc01 --- /dev/null +++ b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor @@ -0,0 +1,68 @@ +@page "/Auth" + + +

Auth

+ +Username (L?, R): +
+Email (L? R): +
+Password (L, R): +
+Type (R): + (one of user|monitor|admin)
+Login +Register +

+ +@if (Exception != null) { +
+ Error:
+
+            @Exception
+        
+
+} + +@if (Result != null) { +
+ Result:
+
+            @Result.ToJson(indent: true)
+        
+
+} + +@code { + private string Username { get; set; } = ""; + private string Email { get; set; } = ""; + private string Password { get; set; } = ""; + private string UserType { get; set; } = ""; + + private Exception? Exception { get; set; } + private object? Result { get; set; } + + private async Task Register() { + Result = null; + Exception = null; + try { + Result = await Authentication.Register(new() { + Username = Username, + Password = Password, + Email = Email, + UserType = UserType + }); + } + catch (Exception ex) { + Exception = ex; + } + finally { + StateHasChanged(); + } + } + + private Task Login() { + throw new NotImplementedException(); + } + +} \ No newline at end of file diff --git a/testFrontend/SafeNSound.Frontend/Pages/Counter.razor b/testFrontend/SafeNSound.Frontend/Pages/Counter.razor deleted file mode 100644 index 372905f..0000000 --- a/testFrontend/SafeNSound.Frontend/Pages/Counter.razor +++ /dev/null @@ -1,19 +0,0 @@ -@page "/counter" - -Counter - -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } - -} \ No newline at end of file -- cgit 1.5.1