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

Choose a login provider to start using the app

@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 Load(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 Start(AuthSchemes[0]); else ShowSelection = true; } private Task Start(AuthSchemeResponse scheme) { Navigation.NavigateTo($"/api/auth/{scheme.Identifier}", true); return Task.CompletedTask; } record AuthSchemeConfig { public string Color { get; set; } public string IconUrl { get; set; } } }