Skip to content

Commit 201db88

Browse files
Multiauth UX Improvements (#78)
1 parent 331d9fc commit 201db88

10 files changed

Lines changed: 66 additions & 40 deletions

File tree

SS14.Launcher/Assets/Locale/en-US/text.ftl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ direct-connect-address-invalid = Address is invalid
7373
## Strings for the "select account" dialog window.
7474
select-account-dialog-title = Select Account
7575
select-account-dialog-header = Select Account
76-
select-account-dialog-description = Your currently selected account is not allowed to connect to this server, pick another one using an allowed authentication provider to join.
76+
select-account-dialog-description =
77+
Your currently selected account is not allowed to connect to this server, pick another one using an allowed account provider to join.
78+
Allowed account providers for this server: { $allowedAuths }
7779
select-account-dialog-error =
78-
You do not have any accounts logged in that can connect to this server.
79-
Click this button to close the dialog.
80+
You do not have any accounts logged in that can connect to this server, exit?
8081
8182
## Strings for the "hub settings" dialog window.
8283

@@ -151,7 +152,7 @@ login-login-auth-server = Account Provider
151152
login-login-button-log-in = Log in
152153
login-login-button-forgot = Forgot your password?
153154
login-login-button-resend = Resend email confirmation
154-
login-login-button-register = Don't have an account? Register!
155+
login-login-button-register = Don't have an account? Register with { $server }!
155156
login-login-busy-logging-in = Logging in…
156157
login-login-error-title = Unable to log in
157158
@@ -386,7 +387,7 @@ server-entry-description-error = Error while fetching server description
386387
server-entry-description-none = No server description provided
387388
server-entry-status-lobby = Lobby
388389
server-entry-tags = Tags:
389-
server-entry-allowed-auths = Allowed Auth Providers:
390+
server-entry-allowed-auths = Allowed Account Providers:
390391
server-fetched-from-hub = Fetched from { $hub }
391392
server-entry-raise = Raise
392393
server-entry-lower = Lower

SS14.Launcher/ConfigConstants.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ public static class ConfigConstants
3838
public static readonly AuthServer TemplateAuthServer = new(new("https://example.com/"), new("https://example.com/"));
3939
public static readonly Dictionary<string, AuthServer> AuthUrls = new()
4040
{
41-
{
42-
"SimpleStation",
43-
new(new("https://auth.simplestation.org/"), new("https://account.simplestation.org/"), true)
44-
},
4541
{
4642
FallbackAuthServer,
4743
new(new("https://auth.spacestation14.com/"), new("https://account.spacestation14.com/"), false)
4844
},
45+
{
46+
"SimpleStation",
47+
new(new("https://auth.simplestation.org/"), new("https://account.simplestation.org/"), true)
48+
},
4949
{
5050
CustomAuthServer,
51-
new (new("https://example.com/"), new("https://example.com/"))
51+
TemplateAuthServer
5252
},
5353
};
5454

SS14.Launcher/Models/Connector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ private async Task LaunchClientWrap(
351351
"(Fallback) " + LoginManager.GetAuthServerById(ConfigConstants.FallbackAuthServer).AuthUrl;
352352
if (account == null)
353353
{
354-
Log.Error("No logged in account found for any of the server's allowed auth providers: {AuthServers}", string.Join(", ", authServers));
354+
Log.Error("No logged in account found for any of the server's allowed account providers: {AuthServers}", string.Join(", ", authServers));
355355
return null;
356356
}
357357
if (account != _loginManager.ActiveAccount &&
358358
!info.AuthInformation.LoginUrls?.Contains(_loginManager.ActiveAccount.ServerUrl) == true)
359359
{
360-
Log.Warning("Using different account than the active one due to server requiring a different auth provider: {Server}", string.Join(", ", authServers));
360+
Log.Warning("Using different account than the active one due to server requiring a different account provider: {Server}", string.Join(", ", authServers));
361361
_loginManager.ActiveAccount = account;
362362
}
363363

SS14.Launcher/ViewModels/Login/ForgotPasswordViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public ForgotPasswordViewModel(
3636
.Subscribe(s =>
3737
{
3838
IsCustom = Server == ConfigConstants.CustomAuthServer;
39-
ServerUrlPlaceholder = LoginManager.GetAuthServerById(IsCustom ? ConfigConstants.AuthUrls.First().Key : Server).AuthUrl.ToString();
39+
ServerUrlPlaceholder = IsCustom ? ServerUrl : LoginManager.GetAuthServerById(Server).AuthUrl.ToString();
4040
IsServerPotentiallyValid = !IsCustom || !Busy && !string.IsNullOrEmpty(EditingEmail) && Uri.TryCreate(ServerUrl, UriKind.Absolute, out _);
4141
});
4242
}

SS14.Launcher/ViewModels/Login/LoginViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class LoginViewModel : BaseLoginViewModel
2525
[Reactive] public string ServerUrlPlaceholder { get; set; } = ConfigConstants.AuthUrls.First().Value.AuthUrl.ToString();
2626
[Reactive] public bool IsCustom { get; private set; }
2727
[Reactive] public bool IsServerPotentiallyValid { get; private set; }
28+
[Reactive] public string RegisterButtonContent { get; private set; } = "";
2829

2930
[Reactive] public string EditingUsername { get; set; } = "";
3031
[Reactive] public string EditingPassword { get; set; } = "";
@@ -47,8 +48,9 @@ public LoginViewModel(MainWindowLoginViewModel parentVm, AuthApi authApi,
4748
? !string.IsNullOrEmpty(s.Item2) && !string.IsNullOrEmpty(s.Item2) && !string.IsNullOrEmpty(s.Item3)
4849
: !string.IsNullOrEmpty(s.Item1) && !string.IsNullOrEmpty(s.Item3);
4950
IsCustom = Server == ConfigConstants.CustomAuthServer;
50-
ServerUrlPlaceholder = LoginManager.GetAuthServerById(IsCustom ? ConfigConstants.AuthUrls.First().Key : Server).AuthUrl.ToString();
51+
ServerUrlPlaceholder = IsCustom ? ServerUrl : LoginManager.GetAuthServerById(Server).AuthUrl.ToString();
5152
IsServerPotentiallyValid = !IsCustom || !Busy && Uri.TryCreate(ServerUrl, UriKind.Absolute, out _);
53+
RegisterButtonContent = _loc.GetString("login-login-button-register", ("server", Server));
5254
});
5355
}
5456

SS14.Launcher/ViewModels/Login/RegisterViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public RegisterViewModel(MainWindowLoginViewModel parentVm, DataManager cfg, Aut
5151
.Subscribe(s =>
5252
{
5353
IsCustom = Server == ConfigConstants.CustomAuthServer;
54-
ServerUrlPlaceholder = LoginManager.GetAuthServerById(IsCustom ? ConfigConstants.AuthUrls.First().Key : Server).AuthUrl.ToString();
54+
ServerUrlPlaceholder = IsCustom ? ServerUrl : LoginManager.GetAuthServerById(Server).AuthUrl.ToString();
5555
IsServerPotentiallyValid = !IsCustom || !Busy && !string.IsNullOrEmpty(EditingEmail) && Uri.TryCreate(ServerUrl, UriKind.Absolute, out _);
5656
});
5757
}

SS14.Launcher/ViewModels/Login/ResendConfirmationViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ResendConfirmationViewModel(MainWindowLoginViewModel parentVM, AuthApi au
3131
.Subscribe(s =>
3232
{
3333
IsCustom = Server == ConfigConstants.CustomAuthServer;
34-
ServerUrlPlaceholder = LoginManager.GetAuthServerById(IsCustom ? ConfigConstants.AuthUrls.First().Key : Server).AuthUrl.ToString();
34+
ServerUrlPlaceholder = IsCustom ? ServerUrl : LoginManager.GetAuthServerById(Server).AuthUrl.ToString();
3535
IsServerPotentiallyValid = !IsCustom || !Busy && !string.IsNullOrEmpty(EditingEmail) && Uri.TryCreate(ServerUrl, UriKind.Absolute, out _);
3636
});
3737
}

SS14.Launcher/Views/Login/LoginView.xaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:v="clr-namespace:SS14.Launcher.Views"
56
xmlns:vml="clr-namespace:SS14.Launcher.ViewModels.Login;assembly=SS14.Launcher"
67
xmlns:loc="clr-namespace:SS14.Launcher.Localization"
78
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
@@ -65,13 +66,15 @@
6566
</DockPanel>
6667

6768
<DockPanel DockPanel.Dock="Top" LastChildFill="False" MaxWidth="500">
68-
<Button DockPanel.Dock="Left" HorizontalAlignment="Center" Content="{loc:Loc login-login-button-resend}"
69-
Command="{Binding ResendConfirmationPressed}"
70-
IsEnabled="{Binding IsServerPotentiallyValid}"/>
69+
<Button DockPanel.Dock="Left" HorizontalAlignment="Center"
70+
Command="{Binding ResendConfirmationPressed}" IsEnabled="{Binding IsServerPotentiallyValid}">
71+
<v:IconLabel Icon="{DynamicResource InfoIcon-web}" Content="{loc:Loc login-login-button-resend}" />
72+
</Button>
7173
</DockPanel>
7274

73-
<Button DockPanel.Dock="Bottom" Classes="BigButton" Margin="0 4" HorizontalAlignment="Center"
74-
Content="{loc:Loc login-login-button-register}" Command="{Binding RegisterPressed}"
75-
IsEnabled="{Binding IsServerPotentiallyValid}" />
75+
<Button DockPanel.Dock="Bottom" Margin="0 4" HorizontalAlignment="Center"
76+
Command="{Binding RegisterPressed}" IsEnabled="{Binding IsServerPotentiallyValid}">
77+
<v:IconLabel Icon="{DynamicResource InfoIcon-web}" FontSize="20" Content="{Binding RegisterButtonContent}" />
78+
</Button>
7679
</DockPanel>
7780
</UserControl>

SS14.Launcher/Views/SelectAccountDialog.xaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:loc="clr-namespace:SS14.Launcher.Localization"
66
xmlns:v="clr-namespace:SS14.Launcher.Views"
7-
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="150"
8-
MinWidth="600" MinHeight="150"
9-
Width="600" Height="150"
7+
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="200"
8+
MinWidth="600" MinHeight="200"
9+
Width="600" Height="200"
1010
x:Class="SS14.Launcher.Views.SelectAccountDialog"
1111
Icon="{DynamicResource WindowIcon}"
1212
Title="{loc:Loc select-account-dialog-title}"
@@ -16,20 +16,26 @@
1616
<v:ScaledControl>
1717
<DockPanel>
1818
<TextBlock DockPanel.Dock="Top" Classes="NanoHeading" Text="{loc:Loc select-account-dialog-header}" />
19-
<TextBlock DockPanel.Dock="Top" Text="{loc:Loc select-account-dialog-description}" TextWrapping="Wrap" />
20-
<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding Accounts, RelativeSource={RelativeSource AncestorType=Window}}" IsVisible="{Binding !Error, RelativeSource={RelativeSource AncestorType=Window}}">
21-
<ItemsControl.ItemTemplate>
22-
<DataTemplate>
23-
<Button Content="{Binding LoginInfo.DisplayName}"
24-
Command="{Binding Confirm, RelativeSource={RelativeSource AncestorType=Window}}"
25-
CommandParameter="{Binding}" />
26-
</DataTemplate>
27-
</ItemsControl.ItemTemplate>
28-
</ItemsControl>
29-
<Button DockPanel.Dock="Top" Content="{loc:Loc select-account-dialog-error}"
30-
Command="{Binding Confirm, RelativeSource={RelativeSource AncestorType=Window}}"
31-
CommandParameter="{Binding SelectedAccount, RelativeSource={RelativeSource AncestorType=Window}}"
32-
IsVisible="{Binding Error, RelativeSource={RelativeSource AncestorType=Window}}" />
19+
<TextBlock DockPanel.Dock="Top" Text="{Binding Description, RelativeSource={RelativeSource AncestorType=Window}}" TextWrapping="Wrap" />
20+
<ScrollViewer DockPanel.Dock="Bottom" Margin="0,8,0,0" HorizontalScrollBarVisibility="Disabled">
21+
<StackPanel>
22+
<ItemsControl ItemsSource="{Binding Accounts, RelativeSource={RelativeSource AncestorType=Window}}" IsVisible="{Binding !Error, RelativeSource={RelativeSource AncestorType=Window}}">
23+
<ItemsControl.ItemTemplate>
24+
<DataTemplate>
25+
<Button Content="{Binding LoginInfo.DisplayName}"
26+
Command="{Binding Confirm, RelativeSource={RelativeSource AncestorType=Window}}"
27+
CommandParameter="{Binding}" />
28+
</DataTemplate>
29+
</ItemsControl.ItemTemplate>
30+
</ItemsControl>
31+
<Button Command="{Binding Confirm, RelativeSource={RelativeSource AncestorType=Window}}"
32+
CommandParameter="{Binding SelectedAccount, RelativeSource={RelativeSource AncestorType=Window}}"
33+
IsVisible="{Binding Error, RelativeSource={RelativeSource AncestorType=Window}}">
34+
<TextBlock Text="{loc:Loc select-account-dialog-error}" TextWrapping="Wrap" />
35+
</Button>
36+
<Button Content="{loc:Loc account-drop-down-add-account}" Command="{Binding AddAccount, RelativeSource={RelativeSource AncestorType=Window}}" />
37+
</StackPanel>
38+
</ScrollViewer>
3339
</DockPanel>
3440
</v:ScaledControl>
3541
</Window>
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,44 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using Avalonia.Controls;
4+
using SS14.Launcher.Localization;
45
using SS14.Launcher.Models.Logins;
56
using SS14.Launcher.Utility;
67

78
namespace SS14.Launcher.Views;
89

910
public partial class SelectAccountDialog : Window
1011
{
12+
private readonly LocalizationManager _loc;
13+
private readonly LoginManager _loginMgr;
14+
1115
public LoggedInAccount? SelectedAccount { get; set; }
1216
public IEnumerable<LoggedInAccount> Accounts { get; set; }
1317
public bool Error { get; set; }
18+
public string Description { get; set; } = string.Empty;
1419

1520
public SelectAccountDialog(string[] authMethods, LoginManager loginManager)
1621
{
1722
InitializeComponent();
1823

19-
Accounts = loginManager.Logins.KeyValues
24+
_loc = LocalizationManager.Instance;
25+
_loginMgr = loginManager;
26+
27+
Accounts = _loginMgr.Logins.KeyValues
2028
.Where(x => authMethods.FirstOrDefault(m => m == ConfigConstants.AuthUrls[x.Value.Server].AuthUrl.AbsoluteUri) != null)
2129
.Select(x => x.Value);
2230
Error = !Accounts.Any();
31+
Description = _loc.GetString("select-account-dialog-description", ("allowedAuths", string.Join(", ", authMethods.Select(m => ConfigConstants.AuthUrls.FirstOrDefault(kv => kv.Value.AuthUrl.AbsoluteUri == m).Key))));
2332
}
2433

2534
public void Confirm(object account)
2635
{
2736
SelectedAccount = account as LoggedInAccount;
2837
Close();
2938
}
39+
40+
public void AddAccount() {
41+
_loginMgr.ActiveAccount = null;
42+
Close();
43+
}
3044
}

0 commit comments

Comments
 (0)