Result:
@Result.ToJson(indent: true)
}
@code {
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() + "@example.com";
Password = Guid.NewGuid().ToString();
UserType = Random.Shared.GetItems(["user", "monitor", "admin"], 1)[0];
StateHasChanged();
}
private async Task Register() {
Result = null;
Exception = null;
try {
await Authentication.Register(new() {
Username = Username,
Password = Password,
Email = Email,
UserType = UserType
});
}
catch (Exception ex) {
Exception = ex;
}
StateHasChanged();
}
private async Task Login() {
Result = null;
Exception = null;
try {
SafeNSoundAuthResult result;
Result = result = await Authentication.Login(new() {
Username = Username,
Password = Password,
Email = Email
});
App.Client = new SafeNSoundClient(Config, result.AccessToken);
}
catch (Exception ex) {
Exception = ex;
}
StateHasChanged();
}
private async Task Delete() {
Result = null;
Exception = null;
try {
await Authentication.Delete(new() {
Username = Username,
Password = Password,
Email = Email
});
}
catch (Exception ex) {
Exception = ex;
}
StateHasChanged();
}
}