3 files changed, 22 insertions, 4 deletions
diff --git a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor
index c58a996..7a9f5d1 100644
--- a/testFrontend/SafeNSound.Frontend/Pages/Auth.razor
+++ b/testFrontend/SafeNSound.Frontend/Pages/Auth.razor
@@ -7,12 +7,13 @@
<span>Email (L? R): </span>
<FancyTextBox @bind-Value="@Email"/><br/>
<span>Password (L, R): </span>
-<FancyTextBox @bind-Value="@Password" IsPassword="true" /><br/>
+<FancyTextBox @bind-Value="@Password" IsPassword="true"/><br/>
<span>Type (R): </span>
<FancyTextBox @bind-Value="@UserType"/><span> (one of user|monitor|admin)</span><br/>
<LinkButton OnClick="@Randomise">Randomise</LinkButton>
<LinkButton OnClick="@Register">Register</LinkButton>
<LinkButton OnClick="@Login">Login</LinkButton>
+<LinkButton OnClick="@WhoAmI">Who Am I</LinkButton>
<LinkButton OnClick="@Delete">Delete</LinkButton>
<br/><br/>
@@ -105,4 +106,16 @@
StateHasChanged();
}
+ private async Task WhoAmI() {
+ Result = null;
+ Exception = null;
+ try {
+ Result = await App.Client!.WhoAmI();
+ }
+ catch (Exception ex) {
+ Exception = ex;
+ }
+ StateHasChanged();
+ }
+
}
\ No newline at end of file
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
index f63d8b0..333db6d 100644
--- a/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
+++ b/testFrontend/SafeNSound.Sdk/SafeNSoundAuthentication.cs
@@ -61,9 +61,6 @@ public class WhoAmI {
[JsonPropertyName("userId")]
public required string UserId { get; set; }
- [JsonPropertyName("username")]
- public required string UserName { get; set; }
-
[JsonPropertyName("deviceId")]
public required string DeviceId { get; set; }
diff --git a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
index 05d0af9..4d81b52 100644
--- a/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
+++ b/testFrontend/SafeNSound.Sdk/SafeNSoundClient.cs
@@ -12,6 +12,14 @@ public class SafeNSoundClient(SafeNSoundConfiguration config, string accessToken
Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken)
}
};
+
+ public async Task<WhoAmI> WhoAmI()
+ {
+ var res = await HttpClient.GetAsync("/auth/whoami");
+ res.EnsureSuccessStatusCode();
+ return (await res.Content.ReadFromJsonAsync<WhoAmI>())!;
+ }
+
#region Alarm
public async Task<AlarmDto> GetAlarm(string userId = "@me") {
|