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 --- .../SafeNSound.Sdk/SafeNSoundAuthentication.cs | 35 ++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs') diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs index 429e93c..cbff880 100644 --- a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs +++ b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs @@ -3,11 +3,6 @@ namespace SafeNSound.Sdk; public class SafeNSoundAuthentication(SafeNSoundConfiguration config) { - // public async Task Login(string username, string password) - // { - - // } - public async Task Register(RegisterDto registerDto) { var hc = new WrappedHttpClient() { BaseAddress = new Uri(config.BaseUri) @@ -16,6 +11,25 @@ public class SafeNSoundAuthentication(SafeNSoundConfiguration config) { var res = await hc.PostAsJsonAsync("/auth/register", registerDto); return null!; } + + public async Task Login(AuthDto authDto) { + var hc = new WrappedHttpClient() { + BaseAddress = new Uri(config.BaseUri) + }; + + var res = await hc.PostAsJsonAsync("/auth/login", authDto); + return null!; + } + + public async Task Delete(AuthDto authDto) { + var hc = new WrappedHttpClient() { + BaseAddress = new Uri(config.BaseUri) + }; + + var res = await hc.DeleteAsJsonAsync("/auth/delete", authDto); + res.EnsureSuccessStatusCode(); + return null!; + } } public class RegisterDto { @@ -32,4 +46,15 @@ public class RegisterDto { public string UserType { get; set; } = string.Empty; } +public class AuthDto { + [JsonPropertyName("username")] + public string Username { get; set; } = string.Empty; + + [JsonPropertyName("password")] + public string Password { get; set; } = string.Empty; + + [JsonPropertyName("email")] + public string Email { get; set; } = string.Empty; +} + public class SafeNSoundAuthResult { } \ No newline at end of file -- cgit 1.5.1