Skip to content

Commit ea68a9d

Browse files
Fix Multiauth (#58)
1 parent b8c650b commit ea68a9d

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

SS14.Launcher/Models/Connector.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,16 @@ private async Task LaunchClientWrap(
326326
if (info != null && info.AuthInformation.Mode != AuthMode.Disabled && _loginManager.ActiveAccount != null)
327327
{
328328
var account = _loginManager.Logins.Items.FirstOrDefault(l =>
329-
info.AuthInformation.LoginUrls?.Contains(LoginManager.GetAuthServerById(l.Server, l.ServerUrl,
330-
LoginManager.TryGetAccountUrl(l.Server, l.ServerUrl)).AuthUrl.ToString()) ?? l.Server == ConfigConstants.FallbackAuthServer);
329+
info.AuthInformation.LoginUrls?.Contains(l.ServerUrl) ?? l.Server == ConfigConstants.FallbackAuthServer);
331330
var authServers = info.AuthInformation.LoginUrls?.ToString() ??
332331
"(Fallback) " + LoginManager.GetAuthServerById(ConfigConstants.FallbackAuthServer).AuthUrl;
333332
if (account == null)
334333
{
335334
Log.Error("No logged in account found for any of the server's allowed auth providers: {AuthServers}", authServers);
336335
return null;
337336
}
338-
if (account != _loginManager.ActiveAccount)
337+
if (account != _loginManager.ActiveAccount &&
338+
!info.AuthInformation.LoginUrls?.Contains(_loginManager.ActiveAccount.ServerUrl) == true)
339339
{
340340
Log.Warning("Using different account than the active one due to server requiring a different auth provider: {Server}", authServers);
341341
_loginManager.ActiveAccount = account;
@@ -348,6 +348,7 @@ private async Task LaunchClientWrap(
348348
cVars.Add(("ROBUST_AUTH_USERID", account.LoginInfo.UserId.ToString()));
349349
cVars.Add(("ROBUST_AUTH_PUBKEY", info.AuthInformation.PublicKey));
350350
cVars.Add(("ROBUST_AUTH_SERVER", authServer));
351+
cVars.Add(("ROBUST_AUTH_SERVERS", $"unset@{authServer}"));
351352
Log.Information($"Launching client with auth server {authServer} and account {account.Username}@{account.Server} ({account.UserId})");
352353
}
353354

SS14.Launcher/Models/ServerStatus/ServerStatusCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static void ApplyStatus(ServerStatusData data, ServerApi.ServerStatus sta
149149
var inferredTags = ServerTagInfer.InferTags(status);
150150

151151
data.Tags = baseTags.Concat(inferredTags).ToArray();
152-
data.Auths = status.AuthMethods ?? [ConfigConstants.FallbackAuthServer];
152+
data.Auths = status.AuthMethods ?? [ConfigConstants.AuthUrls[ConfigConstants.FallbackAuthServer].AuthUrl.AbsoluteUri];
153153
}
154154

155155
public static async void UpdateInfoForCore(ServerStatusData data, Func<CancellationToken, Task<ServerInfo?>> fetch)

SS14.Launcher/ViewModels/Login/LoginViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public static async Task<bool> DoLogin<T>(
8686
if (resp.IsSuccess)
8787
{
8888
var loginInfo = resp.LoginInfo;
89+
loginInfo.ServerUrl ??= ConfigConstants.AuthUrls[ConfigConstants.FallbackAuthServer].AuthUrl.AbsoluteUri;
8990
var oldLogin = loginMgr.Logins.KeyValues.FirstOrDefault(a =>
9091
a.Key == loginInfo.UserId && a.Value.Server == loginInfo.Server
9192
&& a.Value.ServerUrl == loginInfo.ServerUrl).Value;

SS14.Launcher/ViewModels/MainWindowTabs/ServerEntryViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public void Tick()
6868

6969
public void ConnectPressed()
7070
{
71-
// If there is only one supported auth method that matches the active account, connect
72-
if (_cacheData.Auths.Length <= 1 && _cacheData.Auths.Contains(_loginManager.ActiveAccount?.Server))
71+
// If we have an active account that matches the allowed auths, connect
72+
if (_cacheData.Auths.Contains(_loginManager.ActiveAccount?.ServerUrl))
7373
{
7474
ConnectingViewModel.StartConnect(_windowVm, Address);
7575
return;

SS14.Launcher/Views/SelectAccountDialog.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SelectAccountDialog(string[] authMethods, LoginManager loginManager)
1717
InitializeComponent();
1818

1919
Accounts = loginManager.Logins.KeyValues
20-
.Where(x => authMethods.Contains(x.Value.Server))
20+
.Where(x => authMethods.FirstOrDefault(m => m == ConfigConstants.AuthUrls[x.Value.Server].AuthUrl.AbsoluteUri) != null)
2121
.Select(x => x.Value);
2222
Error = !Accounts.Any();
2323
}

0 commit comments

Comments
 (0)