Skip to content

Commit

Permalink
"try fastlogin first" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorovvl committed Jul 18, 2024
1 parent 7cc1a82 commit be93030
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 9 deletions.
8 changes: 7 additions & 1 deletion client/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,15 @@ private void butt_Click_1(object sender, RoutedEventArgs e)
_settings.password = string.Empty;
}
File.WriteAllBytes(setting_file, ProtectedData.Protect(Encoding.UTF8.GetBytes(new JavaScriptSerializer().Serialize(_settings)), additionalEntropy, DataProtectionScope.LocalMachine));
login log = new login() { Owner = ((null == e) ? null : this), username = login.Text, password = password.Password, totpKey = totpkey, region = _region, WindowStartupLocation = ((null == e) ? System.Windows.WindowStartupLocation.CenterScreen : System.Windows.WindowStartupLocation.CenterOwner) };
login log = new login() { Owner = ((null == e) ? null : this), _settings = _settings, username = login.Text, password = password.Password, totpKey = totpkey, region = _region, WindowStartupLocation = ((null == e) ? System.Windows.WindowStartupLocation.CenterScreen : System.Windows.WindowStartupLocation.CenterOwner) };
log.ShowDialog();
if (log.DialogResult == true)
{
if(_settings.tryFast && log.FastLoginSuccess)
{
run_tso();
return;
}
_cookies = log.Cookies;
var tsoUrl = HttpUtility.ParseQueryString(log.Ver);
if (!string.IsNullOrEmpty(_settings.lang))
Expand Down Expand Up @@ -710,6 +715,7 @@ public class clientSettings
public string window { get; set; } = string.Empty;
public string tsofolder { get; set; } = "tso_portable";
public bool x64 { get; set; } = false;
public bool tryFast { get; set; } = false;
public bool configNickname { get; set; } = false;
public string username { get; set; } = string.Empty;
public string password { get; set; } = string.Empty;
Expand Down
6 changes: 4 additions & 2 deletions client/Servers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class Servers
{ "langDropbox", "Dropbox APPKEY:APPSECRET" },
{ "langDropboxRefresh", "Dropbox Refresh token" },
{ "langTestDropbox", "Проверка Dropbox" },
{ "langAuthDropbox", "Авторизация Dropbox" }
{ "langAuthDropbox", "Авторизация Dropbox" },
{ "langTryFast", "Пробовать быструю авторизацию" }
}
},
{ "en-uk", new Dictionary<string, string>() {
Expand Down Expand Up @@ -139,7 +140,8 @@ class Servers
{ "langDropbox", "Dropbox APPKEY:APPSECRET" },
{ "langDropboxRefresh", "Dropbox Refresh token" },
{ "langTestDropbox", "Dropbox test" },
{ "langAuthDropbox", "Dropbox auth" }
{ "langAuthDropbox", "Dropbox auth" },
{ "langTryFast", "Try fastlogin first" }
}
},
{ "fr-fr", new Dictionary<string, string>() {
Expand Down
42 changes: 41 additions & 1 deletion client/login.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Drawing;
using System.Windows.Media.Imaging;
using OtpSharp;
using System.Web;

namespace client
{
Expand All @@ -30,8 +31,12 @@ public partial class login : Window
public string totpKey { get; set; }
public string Ver { get; set; }
public string Session { get; set; }
public clientSettings _settings { get; set; }
public CookieCollection Cookies { get; set; }
private Thread authlogin;
private bool fastSuccess = true;
public bool FastLoginSuccess { get { return fastSuccess; } set { } }

public int attepts = 0;


Expand Down Expand Up @@ -102,11 +107,46 @@ private void Button_Click(object sender, RoutedEventArgs e)
ms.Close();
return deserializedObj;
}

private void FastAuth()
{
var tsoUrl = HttpUtility.ParseQueryString(_settings.tsoArg);
AddToRich("Try fastlogin");
CookieCollection _cookies = new CookieCollection();
PostSubmitter post = new PostSubmitter
{
Url = tsoUrl.Get("bb") + "authenticate",
Type = PostSubmitter.PostTypeEnum.Post
};
post.PostItems.Add("DSOAUTHUSER", tsoUrl.Get("dsoAuthUser"));
post.PostItems.Add("DSOAUTHTOKEN", tsoUrl.Get("dsoAuthToken"));
string res = post.Post(ref _cookies);
if (res.Contains("ERROR"))
{
AddToRich("Fastlogin failed. Back to normal auth");
fastSuccess = false;
MainAuth();
return;
}
AddToRich(Servers.getTrans("launch"));
Dispatcher.BeginInvoke(new ThreadStart(delegate
{
try
{
DialogResult = true;
}
catch { }
}));
return;
}
public void MainAuth()
{
try
{
if(fastSuccess && _settings.tryFast && !string.IsNullOrEmpty(_settings.tsoArg))
{
FastAuth();
return;
}
PostSubmitter post;
string res;
CookieCollection _cookies = new CookieCollection();
Expand Down
25 changes: 20 additions & 5 deletions client/settings.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Window x:Class="client.settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TSO Game Client" Icon="files/icon.ico" Height="431.761" Width="550" MouseLeftButtonDown="titleBar_MouseLeftButtonDown" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="true">
Title="TSO Game Client" Icon="files/icon.ico" Height="463.761" Width="550" MouseLeftButtonDown="titleBar_MouseLeftButtonDown" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="true">
<Window.Background>
<ImageBrush ImageSource="files/settings.png" />
</Window.Background>
Expand Down Expand Up @@ -361,12 +361,27 @@
<TextBlock Height="24" HorizontalAlignment="Left" Margin="38,295,0,0" Foreground="#E9CB6F" FontWeight="Bold" Text="{Binding langNickConfig, Mode=OneWay}" VerticalAlignment="Top" Width="370" Grid.ColumnSpan="2" />
<TextBlock Height="23" HorizontalAlignment="Left" Margin="39,211,0,0" Foreground="#E9CB6F" FontWeight="Bold" Text="{Binding langDropbox, Mode=OneWay}" VerticalAlignment="Top" Width="195" Grid.ColumnSpan="2" />
<TextBlock Height="23" HorizontalAlignment="Left" Margin="39,239,0,0" Foreground="#E9CB6F" FontWeight="Bold" Text="{Binding langDropboxRefresh, Mode=OneWay}" VerticalAlignment="Top" Width="195" Grid.ColumnSpan="2" />
<TextBlock Height="24" HorizontalAlignment="Left" Margin="38,324,0,-12" Foreground="#E9CB6F" FontWeight="Bold" Text="{Binding langTryFast, Mode=OneWay}" VerticalAlignment="Top" Width="370" Grid.ColumnSpan="2" />
<CheckBox Height="25" IsChecked="True" x:Name="tryFast" Margin="292,323,23.2,-12" Width="24" Grid.Column="1">
<CheckBox.Template>
<ControlTemplate TargetType="{x:Type CheckBox}">
<StackPanel Orientation="Horizontal">
<Image x:Name="_image" Source="files/unchecked.png" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Source" TargetName="_image" Value="files/checked.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
</Grid>
</GroupBox>
<Button BorderThickness="0" Content="{Binding langSave, Mode=OneWay}" Click="Button_Click" Height="23" HorizontalAlignment="Left" Margin="360,347,0,0" VerticalAlignment="Top" Width="77" />
<Button BorderThickness="0" Content="{Binding langExit, Mode=OneWay}" Click="Button_Click_1" Height="23" HorizontalAlignment="Left" Margin="442,347,0,0" VerticalAlignment="Top" Width="77" />
<Button BorderThickness="0" Content="{Binding langTestDropbox, Mode=OneWay}" Click="Button_Click_2" Height="23" HorizontalAlignment="Left" Margin="25,347,0,0" VerticalAlignment="Top" Width="135" />
<Button BorderThickness="0" Content="{Binding langAuthDropbox, Mode=OneWay}" Click="Button_Click_3" Height="23" HorizontalAlignment="Left" Margin="165,347,0,0" VerticalAlignment="Top" Width="135" />
<Button BorderThickness="0" Content="{Binding langSave, Mode=OneWay}" Click="Button_Click" Height="23" HorizontalAlignment="Left" Margin="364,375,0,0" VerticalAlignment="Top" Width="77" />
<Button BorderThickness="0" Content="{Binding langExit, Mode=OneWay}" Click="Button_Click_1" Height="23" HorizontalAlignment="Left" Margin="446,375,0,0" VerticalAlignment="Top" Width="77" />
<Button BorderThickness="0" Content="{Binding langTestDropbox, Mode=OneWay}" Click="Button_Click_2" Height="23" HorizontalAlignment="Left" Margin="29,375,0,0" VerticalAlignment="Top" Width="135" />
<Button BorderThickness="0" Content="{Binding langAuthDropbox, Mode=OneWay}" Click="Button_Click_3" Height="23" HorizontalAlignment="Left" Margin="169,375,0,0" VerticalAlignment="Top" Width="135" />
<Button BorderThickness="0" Content="֎" ToolTip="Get auth code" Click="Button_Click_4" Height="29" HorizontalAlignment="Left" Margin="485,217,0,0" VerticalAlignment="Top" Width="34" FontSize="20" />
</Grid>
</Window>
3 changes: 3 additions & 0 deletions client/settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public partial class settings : Window
public string langDropboxRefresh { get { return Servers.getTrans("langDropboxRefresh"); } set { } }
public string langTestDropbox { get { return Servers.getTrans("langTestDropbox"); } set { } }
public string langAuthDropbox { get { return Servers.getTrans("langAuthDropbox"); } set { } }
public string langTryFast { get { return Servers.getTrans("langTryFast"); } set { } }
public string[] winSizes = new string[] { "", "maximized", "minimized", "fullscreen" };
public string[] langs = new string[] { "", "de", "us", "en", "fr", "ru", "pl", "es", "nl", "cz", "pt", "it", "el", "ro" };

Expand All @@ -58,6 +59,7 @@ private void settings_Loaded(object sender, RoutedEventArgs e)
tsofolder.Text = setting.tsofolder;
clientconfig.Text = setting.clientconfig;
nicknameConfig.IsChecked = setting.configNickname;
tryFast.IsChecked = setting.tryFast;
if (!string.IsNullOrEmpty(setting.window))
{
window_size.SelectedIndex = Array.IndexOf(winSizes, setting.window);
Expand All @@ -82,6 +84,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
setting.dropboxrefresh = dropboxRefresh.Text.Trim();
setting.x64 = (bool)x64runtime.IsChecked;
setting.configNickname = (bool)nicknameConfig.IsChecked;
setting.tryFast = (bool)tryFast.IsChecked;
setting.tsofolder = tsofolder.Text.Trim();
setting.clientconfig = clientconfig.Text.Trim();
setting.window = winSizes[window_size.SelectedIndex];
Expand Down

0 comments on commit be93030

Please sign in to comment.