@using MoonCore.Helpers @using Moonlight.Shared.Http.Responses.Auth @inject HttpApiClient ApiClient @inject NavigationManager Navigation
@if (ShowSelection) {
brand-logo

Login into your account

Chose a login method to continue

@if (AuthSchemes.Length == 0) {
No auth schemes enabled/available
}
@foreach (var scheme in AuthSchemes) { var config = Configs.GetValueOrDefault(scheme.Identifier); if (config == null) // Ignore all schemes which have no ui configured continue; }
} else {
}
@code { private AuthSchemeResponse[] AuthSchemes; private Dictionary Configs = new(); private bool ShowSelection = false; protected override void OnInitialized() { Configs["LocalAuth"] = new AuthSchemeConfig() { Color = "#7636e3", IconUrl = "/placeholder.jpg" }; } private async Task LoadAsync(LazyLoader arg) { AuthSchemes = await ApiClient.GetJson( "api/auth" ); // If we only have one auth scheme available // we want to auto redirect the user without // showing the selection screen if (AuthSchemes.Length == 1) await StartAsync(AuthSchemes[0]); else ShowSelection = true; } private Task StartAsync(AuthSchemeResponse scheme) { Navigation.NavigateTo($"/api/auth/{scheme.Identifier}", true); return Task.CompletedTask; } record AuthSchemeConfig { public string Color { get; set; } public string IconUrl { get; set; } } }