Skip to content

Commit da9463f

Browse files
committed
Added new filter for early access for file and metadata at the same time + game settings early access will now show current state
1 parent 6540ec2 commit da9463f

10 files changed

Lines changed: 34 additions & 31 deletions

gamevault/Helper/LoginManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public async Task<LoginState> Login(string serverUrl, string username, string pa
113113
return state;
114114
}
115115

116-
public async Task<LoginState> OAuthLogin(UserProfile profile, bool showWindow = true)
116+
public async Task<LoginState> SSOLogin(UserProfile profile, bool showWindow = true)
117117
{
118118
// Create window in both cases, but only show it if showWindow is true
119119
Window win = new Window()
@@ -195,8 +195,8 @@ public async Task<LoginState> OAuthLogin(UserProfile profile, bool showWindow =
195195
// Otherwise, let the navigation continue
196196
}
197197
};
198-
uiWebView.CoreWebView2.Navigate($"{profile.ServerUrl}/api/auth/oauth2/login");
199-
// uiWebView.Source = new Uri($"{profile.ServerUrl}/api/auth/oauth2/login");
198+
uiWebView.CoreWebView2.Navigate($"{profile.ServerUrl}/api/auth/SSO2/login");
199+
// uiWebView.Source = new Uri($"{profile.ServerUrl}/api/auth/SSO2/login");
200200

201201
// Set a timeout for hidden window mode
202202
if (!showWindow)
@@ -442,8 +442,8 @@ private async void CheckOnlineStatus(object sender, EventArgs e)
442442
{
443443
if (!IsLoggedIn())
444444
{
445-
bool isLoggedInWithOAuth = Preferences.Get(AppConfigKey.IsLoggedInWithOAuth, GetUserProfile().UserConfigFile) == "1";
446-
if (!isLoggedInWithOAuth)
445+
bool isLoggedInWithSSO = Preferences.Get(AppConfigKey.IsLoggedInWithSSO, GetUserProfile().UserConfigFile) == "1";
446+
if (!isLoggedInWithSSO)
447447
{
448448
string[] credencials = WebHelper.GetCredentials();
449449
await Login(GetUserProfile().ServerUrl, credencials[0], credencials[1]);

gamevault/Helper/Web/OAuthHttpClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace gamevault.Helper
1313
{
14-
public class OAuthHttpClient
14+
public class SSOHttpClient
1515
{
1616
private readonly HttpClient _httpClient;
1717
private string _accessToken;
@@ -21,7 +21,7 @@ public class OAuthHttpClient
2121
public string UserName;
2222
public string Password;
2323

24-
public OAuthHttpClient()
24+
public SSOHttpClient()
2525
{
2626
_httpClient = new HttpClient();
2727
_httpClient.DefaultRequestHeaders.UserAgent.ParseAdd($"GameVault/{SettingsViewModel.Instance.Version}");

gamevault/Helper/Web/WebHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace gamevault.Helper
2121
{
2222
internal class WebHelper
2323
{
24-
private static readonly OAuthHttpClient HttpClient = new OAuthHttpClient();
24+
private static readonly SSOHttpClient HttpClient = new SSOHttpClient();
2525
private static readonly HttpClient BaseHttpClient = new HttpClient();
2626
static WebHelper() { }
2727
internal static void SetCredentials(string serverUrl, string username, string password)

gamevault/Models/AppInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public enum AppConfigKey
5858
UserID,
5959
LoginRememberMe,
6060
LastUserProfile,
61-
IsLoggedInWithOAuth,
61+
IsLoggedInWithSSO,
6262
LastImageOptimization
6363

6464
}

gamevault/UserControls/GameSettingsUserControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@
633633
<TextBox Width="100" Margin="115,0,0,0" mah:TextBoxHelper.Watermark="{Binding Game.Metadata.AgeRating}" mah:TextBoxHelper.UseFloatingWatermark="True" Text="{Binding UpdateGame.UserMetadata.AgeRating,TargetNullValue='',FallbackValue={x:Null}}" mah:ControlsHelper.CornerRadius="5"/>
634634
<DatePicker Width="100" Margin="69,0,0,0" SelectedDate="{Binding UpdateGame.UserMetadata.ReleaseDate}" mah:TextBoxHelper.Watermark="{Binding Path=Game.Metadata.ReleaseDate,StringFormat='{}{0:dd/MM/yyyy}'}" mah:ControlsHelper.CornerRadius="5" mah:TextBoxHelper.UseFloatingWatermark="True"/>
635635
<TextBox Width="100" Margin="67,0,0,0" mah:TextBoxHelper.Watermark="{Binding Game.Metadata.Rating}" mah:TextBoxHelper.UseFloatingWatermark="True" Text="{Binding UpdateGame.UserMetadata.Rating}" mah:ControlsHelper.CornerRadius="5"/>
636-
<CheckBox Content="Yes" IsChecked="{Binding UpdateGame.UserMetadata.EarlyAccess}" Margin="68,0,0,0"/>
636+
<CheckBox Content="{Binding Game.Metadata.EarlyAccess}" IsChecked="{Binding UpdateGame.UserMetadata.EarlyAccess}" Margin="68,0,0,0"/>
637637
</StackPanel>
638638

639639
<TextBlock Text="Default Launch Executable" FontSize="15" FontWeight="Bold" TextDecorations="Underline" Margin="0,5,0,5"/>

gamevault/UserControls/GameViewUserControl.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,17 @@
257257
<TextBlock Text="{Binding Path=Game.Type,Converter={StaticResource enumDescConv}}" VerticalAlignment="Center" Margin="8,0,8,0" FontSize="10" FontWeight="Bold" Foreground="#FF424242"/>
258258
</Border>
259259
</Button>
260-
<Border CornerRadius="5" Background="Gainsboro" Height="25" Margin="0,0,0,0">
260+
<Border CornerRadius="5" Background="Gainsboro" Height="25" Margin="5,0,0,0">
261261
<Border.Style>
262262
<Style TargetType="{x:Type Border}">
263263
<Setter Property="Visibility" Value="Collapsed"/>
264264
<Style.Triggers>
265265
<DataTrigger Binding="{Binding Path=Game.EarlyAccess}" Value="True">
266266
<Setter Property="Visibility" Value="Visible"/>
267267
</DataTrigger>
268+
<DataTrigger Binding="{Binding Path=Game.Metadata.EarlyAccess}" Value="True">
269+
<Setter Property="Visibility" Value="Visible"/>
270+
</DataTrigger>
268271
</Style.Triggers>
269272
</Style>
270273
</Border.Style>

gamevault/UserControls/LibraryUserControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private string ApplyFilter(string filter)
292292
}
293293
if (uiFilterEarlyAccess.IsChecked == true)
294294
{
295-
filter += "&filter.early_access=$eq:true";
295+
filter += "&filter.early_access=$eq:true&filter.metadata.early_access=$eq:true";
296296
}
297297
if (uiFilterReleaseDateRangeSelector.IsValid())
298298
{

gamevault/UserControls/SettingsUserControl.xaml.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ private async void Logout_Click(object sender, RoutedEventArgs e)
168168
{
169169
try
170170
{
171-
bool isLoggedInWithOAuth = Preferences.Get(AppConfigKey.IsLoggedInWithOAuth, LoginManager.Instance.GetUserProfile().UserConfigFile) == "1";
172-
if (isLoggedInWithOAuth)
171+
bool isLoggedInWithSSO = Preferences.Get(AppConfigKey.IsLoggedInWithSSO, LoginManager.Instance.GetUserProfile().UserConfigFile) == "1";
172+
if (isLoggedInWithSSO)
173173
{
174174
//await WebHelper.PostAsync($"{SettingsViewModel.Instance.ServerUrl}/api/auth/revoke", "{" + $"\"refresh_token\": \"{WebHelper.GetRefreshToken()}\"" + "}");
175175
}
@@ -197,14 +197,14 @@ private async void LogoutFromAllDevices_Click(object sender, RoutedEventArgs e)
197197
//{
198198
// try
199199
// {
200-
// bool isLoggedInWithOAuth = Preferences.Get(AppConfigKey.IsLoggedInWithOAuth, LoginManager.Instance.GetUserProfile().UserConfigFile) == "1";
201-
// if (isLoggedInWithOAuth)
200+
// bool isLoggedInWithSSO = Preferences.Get(AppConfigKey.IsLoggedInWithSSO, LoginManager.Instance.GetUserProfile().UserConfigFile) == "1";
201+
// if (isLoggedInWithSSO)
202202
// {
203203
// await WebHelper.PostAsync($"{SettingsViewModel.Instance.ServerUrl}/api/auth/revoke/all", "");
204204
// }
205205
// else
206206
// {
207-
// MainWindowViewModel.Instance.AppBarText = "This action is only possible if the user is logged in via OAuth";
207+
// MainWindowViewModel.Instance.AppBarText = "This action is only possible if the user is logged in via SSO";
208208
// }
209209
// }
210210
// catch (Exception ex)

gamevault/Windows/LoginWindow.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<TextBlock Text="Sign In" FontSize="30" HorizontalAlignment="Center"/>
171171
<TextBlock Text="Specify Your Server URL" TextDecorations="Underline" Margin="0,15,0,5"/>
172172
<TextBox Text="{Binding LoginUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
173-
<StackPanel IsEnabled="{Binding LoginUser.IsLoggedInWithOAuth,Converter={StaticResource invBoolConv}}">
173+
<StackPanel IsEnabled="{Binding LoginUser.IsLoggedInWithSSO,Converter={StaticResource invBoolConv}}">
174174
<TextBlock Text="Username or Email" TextDecorations="Underline" Margin="0,15,0,5"/>
175175
<TextBox Text="{Binding LoginUser.Username}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
176176

@@ -182,7 +182,7 @@
182182
<TextBlock Text="OR" HorizontalAlignment="Center" Margin="10,0,10,0"/>
183183
<Rectangle Fill="{DynamicResource MahApps.Brushes.ThemeForeground}" Width="70" Height="2"/>
184184
</StackPanel>
185-
<CheckBox IsChecked="{Binding LoginUser.IsLoggedInWithOAuth}" Content="Sign in using your Identity Provider" mah:CheckBoxHelper.CheckCornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,15,0,0"/>
185+
<CheckBox IsChecked="{Binding LoginUser.IsLoggedInWithSSO}" Content="Sign in using your Identity Provider" mah:CheckBoxHelper.CheckCornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,15,0,0"/>
186186
</StackPanel>
187187
<uc:IconButton Text="Save and Login" Height="30" Margin="0,0,10,10" Width="100" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="SaveAndLogin_Click"/>
188188
<uc:IconButton Text="Back" Kind="Skeleton" BorderThickness="1" Height="30" Margin="10,0,0,10" Width="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="Back_Click" Tag="{x:Static local:LoginStep.SignInOrSignUp}"/>
@@ -194,7 +194,7 @@
194194
<TextBlock Text="Sign Up" FontSize="30" HorizontalAlignment="Center"/>
195195
<TextBlock Text="Specify Your Server URL" TextDecorations="Underline" Margin="0,15,0,5"/>
196196
<TextBox Text="{Binding SignupUser.ServerUrl}" mah:ControlsHelper.CornerRadius="5" BorderThickness="2"/>
197-
<StackPanel IsEnabled="{Binding SignupUser.IsLoggedInWithOAuth,Converter={StaticResource invBoolConv}}">
197+
<StackPanel IsEnabled="{Binding SignupUser.IsLoggedInWithSSO,Converter={StaticResource invBoolConv}}">
198198
<Grid>
199199
<Grid.ColumnDefinitions>
200200
<ColumnDefinition Width="Auto"/>
@@ -248,7 +248,7 @@
248248
<Rectangle Fill="{DynamicResource MahApps.Brushes.ThemeForeground}" Width="70" Height="2"/>
249249
</StackPanel>
250250
</StackPanel>
251-
<CheckBox IsChecked="{Binding SignupUser.IsLoggedInWithOAuth}" Content="Sign up using your Identity Provider" mah:CheckBoxHelper.CheckCornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,15,0,0"/>
251+
<CheckBox IsChecked="{Binding SignupUser.IsLoggedInWithSSO}" Content="Sign up using your Identity Provider" mah:CheckBoxHelper.CheckCornerRadius="5" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,15,0,0"/>
252252
</StackPanel>
253253
<uc:IconButton Text="Save and Sign Up" Height="30" Margin="0,0,10,10" Width="100" HorizontalAlignment="Right" VerticalAlignment="Bottom" Click="SaveAndSignUp_Click"/>
254254
<uc:IconButton Text="Back" Kind="Skeleton" BorderThickness="1" Height="30" Margin="10,0,0,10" Width="100" HorizontalAlignment="Left" VerticalAlignment="Bottom" Click="Back_Click" Tag="{x:Static local:LoginStep.SignInOrSignUp}"/>

gamevault/Windows/LoginWindow.xaml.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class LoginUser
2828
public string FirstName { get; set; }
2929
public string LastName { get; set; }
3030
public string EMail { get; set; }
31-
public bool IsLoggedInWithOAuth { get; set; }
31+
public bool IsLoggedInWithSSO { get; set; }
3232
}
3333
public enum LoginStep
3434
{
@@ -114,7 +114,7 @@ private UserProfile SetupUserProfile(LoginUser user)
114114
UserProfile profile = ProfileManager.CreateUserProfile(cleanedServerUrl);
115115
profile.ServerUrl = user.ServerUrl;
116116
Preferences.Set(AppConfigKey.ServerUrl, user.ServerUrl, profile.UserConfigFile);
117-
if (!user.IsLoggedInWithOAuth)
117+
if (!user.IsLoggedInWithSSO)
118118
{
119119
profile.Name = user.Username;
120120
ViewModel.UserProfiles.Add(profile);
@@ -123,7 +123,7 @@ private UserProfile SetupUserProfile(LoginUser user)
123123
}
124124
else
125125
{
126-
Preferences.Set(AppConfigKey.IsLoggedInWithOAuth, "1", profile.UserConfigFile);
126+
Preferences.Set(AppConfigKey.IsLoggedInWithSSO, "1", profile.UserConfigFile);
127127
}
128128
return profile;
129129
}
@@ -165,7 +165,7 @@ private void ValidateSignInData(LoginUser loginUser)
165165

166166
loginUser.ServerUrl = ValidateUriScheme(loginUser.ServerUrl);
167167

168-
if (!ViewModel.LoginUser.IsLoggedInWithOAuth)
168+
if (!ViewModel.LoginUser.IsLoggedInWithSSO)
169169
{
170170
if (string.IsNullOrWhiteSpace(loginUser.Username))
171171
throw new ArgumentException("Username is not set");
@@ -182,17 +182,17 @@ private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool
182182
ViewModel.StatusText = "Logging in...";
183183
ViewModel.LoginStepIndex = (int)LoginStep.LoadingAction;
184184
}
185-
bool isLoggedInWithOAuth = Preferences.Get(AppConfigKey.IsLoggedInWithOAuth, profile.UserConfigFile) == "1";
185+
bool isLoggedInWithSSO = Preferences.Get(AppConfigKey.IsLoggedInWithSSO, profile.UserConfigFile) == "1";
186186
LoginState state = LoginState.Success;
187-
if (!isLoggedInWithOAuth)
187+
if (!isLoggedInWithSSO)
188188
{
189189
string username = Preferences.Get(AppConfigKey.Username, profile.UserConfigFile);
190190
string password = Preferences.Get(AppConfigKey.Password, profile.UserConfigFile, true);
191191
state = await LoginManager.Instance.Login(profile.ServerUrl, username, password);
192192
}
193193
else
194194
{
195-
state = await LoginManager.Instance.OAuthLogin(profile, firstTimeLogin);
195+
state = await LoginManager.Instance.SSOLogin(profile, firstTimeLogin);
196196
if (state == LoginState.Success)
197197
{
198198
Preferences.Set(AppConfigKey.Username, LoginManager.Instance.GetCurrentUser().Username, profile.UserConfigFile);
@@ -206,7 +206,7 @@ private async Task Login(UserProfile profile, bool firstTimeLogin = false, bool
206206
}
207207
catch
208208
{
209-
await Task.Delay(1500);//For slower machines, we have to wait for the webview of OAuthLogin to free the web cache
209+
await Task.Delay(1500);//For slower machines, we have to wait for the webview of SSOLogin to free the web cache
210210
ProfileManager.DeleteUserProfile(profile);
211211
}
212212
}
@@ -259,7 +259,7 @@ private async void SaveAndSignUp_Click(object sender, RoutedEventArgs e)
259259
{
260260
ValidateSignUpData();
261261
LoginState state = LoginState.Success;
262-
if (!ViewModel.SignupUser.IsLoggedInWithOAuth)
262+
if (!ViewModel.SignupUser.IsLoggedInWithSSO)
263263
{
264264
state = await LoginManager.Instance.Register(ViewModel.SignupUser);//Only non-provider login has a additional call. Else its just a login, because the server will create the account internally
265265
}
@@ -289,7 +289,7 @@ private void ValidateSignUpData()
289289
throw new Exception("Server URL is not set");
290290
}
291291
ViewModel.SignupUser.ServerUrl = ValidateUriScheme(ViewModel.SignupUser.ServerUrl);
292-
if (!ViewModel.SignupUser.IsLoggedInWithOAuth)
292+
if (!ViewModel.SignupUser.IsLoggedInWithSSO)
293293
{
294294
if (string.IsNullOrWhiteSpace(ViewModel.SignupUser.Password) || string.IsNullOrWhiteSpace(ViewModel.SignupUser.RepeatPassword))
295295
{

0 commit comments

Comments
 (0)