From 17a85b1c9f8d58dd8c2197b3623c848036443bb3 Mon Sep 17 00:00:00 2001 From: Tim Pilius Date: Thu, 19 Dec 2024 19:44:24 -0500 Subject: [PATCH] Properly handling passwords that are longer than 64 characters. Anything longer than 64 characters will be truncated before attempting to login --- SteamPrefill/Extensions/MiscExtensions.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SteamPrefill/Extensions/MiscExtensions.cs b/SteamPrefill/Extensions/MiscExtensions.cs index e100e6ef..98fab8c4 100644 --- a/SteamPrefill/Extensions/MiscExtensions.cs +++ b/SteamPrefill/Extensions/MiscExtensions.cs @@ -37,12 +37,16 @@ public static void Shuffle(this IList list) public static async Task ReadPasswordAsync(this IAnsiConsole console, string promptText = null) { - var promptTask = Task.Run(() => + // Wrapping the prompt in a task so that we can add a timeout if the user doesn't enter a password + Task promptTask = Task.Run(() => { var defaultPrompt = $"Please enter your {Cyan("Steam password")}. {LightYellow("(Password won't be saved)")} : "; - return console.Prompt(new TextPrompt(promptText ?? defaultPrompt) + var password = console.Prompt(new TextPrompt(promptText ?? defaultPrompt) .PromptStyle("white") .Secret()); + + // For whatever reason Steam allows you to enter as long of a password as you'd like, and silently truncates anything after 64 characters + return password.Substring(0, 64); }); return await promptTask.WaitAsync(TimeSpan.FromSeconds(30)); }