From 6e4a764bb902988eed7065f092d3bb07b311038c Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 26 Jul 2017 18:30:29 -0400 Subject: [PATCH] Add support for remembering password (loginkey). --- DepotDownloader/ConfigStore.cs | 3 +++ DepotDownloader/ContentDownloader.cs | 2 ++ DepotDownloader/DownloadConfig.cs | 2 ++ DepotDownloader/Program.cs | 3 ++- DepotDownloader/Steam3Session.cs | 9 +++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/DepotDownloader/ConfigStore.cs b/DepotDownloader/ConfigStore.cs index 34e0b803..c3594af7 100644 --- a/DepotDownloader/ConfigStore.cs +++ b/DepotDownloader/ConfigStore.cs @@ -20,6 +20,9 @@ namespace DepotDownloader [ProtoMember(4, IsRequired = false)] public System.Collections.Concurrent.ConcurrentDictionary ContentServerPenalty { get; private set; } + [ProtoMember(5, IsRequired = false)] + public Dictionary LoginKeys { get; private set; } + string FileName = null; ConfigStore() diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 564b63c4..d5a920a2 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -339,6 +339,8 @@ namespace DepotDownloader { Username = username, Password = password, + ShouldRememberPassword = Config.RememberPassword, + LoginKey = ConfigStore.TheConfig.LoginKeys.ContainsKey(username) ? ConfigStore.TheConfig.LoginKeys[username] : null, } ); diff --git a/DepotDownloader/DownloadConfig.cs b/DepotDownloader/DownloadConfig.cs index 84fc1b22..06e256e0 100644 --- a/DepotDownloader/DownloadConfig.cs +++ b/DepotDownloader/DownloadConfig.cs @@ -24,5 +24,7 @@ namespace DepotDownloader public int MaxServers { get; set; } public int MaxDownloads { get; set; } + + public bool RememberPassword { get; set; } } } diff --git a/DepotDownloader/Program.cs b/DepotDownloader/Program.cs index 88020251..0eeea418 100644 --- a/DepotDownloader/Program.cs +++ b/DepotDownloader/Program.cs @@ -87,6 +87,7 @@ namespace DepotDownloader string username = GetParameter(args, "-username") ?? GetParameter(args, "-user"); string password = GetParameter(args, "-password") ?? GetParameter(args, "-pass"); + ContentDownloader.Config.RememberPassword = HasParameter(args, "-remember-password"); ContentDownloader.Config.InstallDirectory = GetParameter(args, "-dir"); ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms"); ContentDownloader.Config.VerifyAll = HasParameter(args, "-verify-all") || HasParameter(args, "-verify_all") || HasParameter(args, "-validate"); @@ -97,7 +98,7 @@ namespace DepotDownloader ContentDownloader.Config.MaxServers = Math.Max(ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads); - if (username != null && password == null) + if (username != null && password == null && !ConfigStore.TheConfig.LoginKeys.ContainsKey(username)) { Console.Write("Enter account password for \"{0}\": ", username); password = Util.ReadPassword(); diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index cb098007..a4b73158 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -94,6 +94,7 @@ namespace DepotDownloader this.callbacks.Subscribe(SessionTokenCallback); this.callbacks.Subscribe(LicenseListCallback); this.callbacks.Subscribe(UpdateMachineAuthCallback); + this.callbacks.Subscribe(LoginKeyCallback); Console.Write( "Connecting to Steam3..." ); @@ -563,6 +564,14 @@ namespace DepotDownloader steamUser.SendMachineAuthResponse( authResponse ); } + private void LoginKeyCallback(SteamUser.LoginKeyCallback loginKey) + { + ConfigStore.TheConfig.LoginKeys[logonDetails.Username] = loginKey.LoginKey; + ConfigStore.Save(); + + steamUser.AcceptNewLoginKey(loginKey); + } + } }