2025-01-05 21:09:57 -06:00
|
|
|
@using LANCommander.SDK.Models
|
|
|
|
|
@using Newtonsoft.Json
|
|
|
|
|
@using Photino.NET
|
2025-10-15 21:47:28 -05:00
|
|
|
@namespace LANCommander.Launcher.UI
|
2025-12-31 20:01:04 -06:00
|
|
|
@inject IConnectionClient ConnectionClient
|
|
|
|
|
@inject AuthenticationClient AuthenticationClient
|
2025-01-05 21:09:57 -06:00
|
|
|
@inject IMessageService MessageService
|
|
|
|
|
@inject ILogger<AuthenticationProviderDialog> Logger
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
@inject LocalizationService LocalizationService
|
2025-01-05 21:09:57 -06:00
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public EventCallback<AuthToken> OnTokenReceived { get; set; }
|
|
|
|
|
|
2025-09-24 20:58:23 -05:00
|
|
|
Uri AuthenticationProviderLoginUrl;
|
2025-01-05 21:09:57 -06:00
|
|
|
|
|
|
|
|
PhotinoWindow Window;
|
|
|
|
|
|
2025-09-24 20:58:23 -05:00
|
|
|
public async Task Open(Uri baseUrl, AuthenticationProvider authenticationProvider)
|
2025-01-05 21:09:57 -06:00
|
|
|
{
|
2025-12-31 20:01:04 -06:00
|
|
|
await ConnectionClient.UpdateServerAddressAsync(baseUrl);
|
2025-01-05 21:09:57 -06:00
|
|
|
|
2025-12-31 20:01:04 -06:00
|
|
|
AuthenticationProviderLoginUrl = AuthenticationClient.GetAuthenticationProviderLoginUrl(authenticationProvider.Slug);
|
2025-01-05 21:09:57 -06:00
|
|
|
|
|
|
|
|
Window = new PhotinoWindow()
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
.SetTitle(LocalizationService.GetString("SignInUsingProvider", authenticationProvider.Name))
|
2025-01-05 21:09:57 -06:00
|
|
|
.Load(AuthenticationProviderLoginUrl)
|
|
|
|
|
.SetContextMenuEnabled(false);
|
|
|
|
|
|
|
|
|
|
Window.RegisterWebMessageReceivedHandler(MessageHandler);
|
|
|
|
|
|
|
|
|
|
Window.WaitForClose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async void MessageHandler(object? sender, string message)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var token = JsonConvert.DeserializeObject<AuthToken>(message);
|
|
|
|
|
|
|
|
|
|
await InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
OnTokenReceived.InvokeAsync(token);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.LogError(ex, "Could not process login");
|
Add localization support to launcher
Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
2025-08-18 21:29:38 -05:00
|
|
|
MessageService.Error(LocalizationService.GetString("CouldNotProcessLogin"));
|
2025-01-05 21:09:57 -06:00
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Window.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|