@page "/HSEInit"
@inject ILocalStorageService LocalStorage
@inject IJSRuntime JsRuntime
HSE Initialising...
@code {
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
var tasks = Enumerable.Range(0, 50).Select(i => Login()).ToList();
await Task.WhenAll(tasks);
Console.WriteLine("All logins complete!");
var userAuths = tasks.Select(t => t.Result).Where(t => t != null).ToList();
await LocalStorage.SetItemAsync("rmu.tokens", userAuths);
NavigationManager.NavigateTo("/", true);
}
async Task Login() {
try {
var result = new UserAuth(await hsProvider.Login("http://localhost:5298", $"{Guid.NewGuid().ToString()}", ""));
if (result == null) {
Console.WriteLine($"Failed to login!");
return null;
}
Console.WriteLine($"Obtained access token for {result.UserId}!");
return result;
}
catch (Exception e) {
// Console.WriteLine($"Failed to login to {record.Homeserver} as {record.Username}!");
Console.WriteLine(e);
// record.Exception = e;
}
return null;
}
}