From c5034a23ad94d521f74336207e4da33da2ebb03b Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 13 Apr 2015 23:31:38 -0600 Subject: [PATCH] Turns out that OmniServer doesn't refactor after all, who knew? Fix build. --- TShockAPI/DB/UserManager.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/TShockAPI/DB/UserManager.cs b/TShockAPI/DB/UserManager.cs index be6a418a..0026cbc6 100755 --- a/TShockAPI/DB/UserManager.cs +++ b/TShockAPI/DB/UserManager.cs @@ -355,16 +355,16 @@ namespace TShockAPI.DB if (BCrypt.Net.BCrypt.Verify(password, this.Password)) { // If necessary, perform an upgrade to the highest work factor. - upgradePasswordWorkFactor(password); + UpgradePasswordWorkFactor(password); return true; } } catch (SaltParseException) { - if (hashPassword(password).ToUpper() == this.Password.ToUpper()) + if (HashPassword(password).ToUpper() == this.Password.ToUpper()) { // The password is not stored using BCrypt; upgrade it to BCrypt immediately - upgradePasswordToBCrypt(password); + UpgradePasswordToBCrypt(password); return true; } return false; @@ -406,13 +406,15 @@ namespace TShockAPI.DB protected internal void UpgradePasswordWorkFactor(string password) { // If the destination work factor is not greater, we won't upgrade it or re-hash it + int currentWorkFactor = 0; try { - int currentWorkFactor = Int32.Parse((this.Password.Split('$')[2])); + currentWorkFactor = Int32.Parse((this.Password.Split('$')[2])); } catch (FormatException) { TShock.Log.ConsoleError("Warning: Not upgrading work factor because bcrypt hash in an invalid format."); + return; } if (currentWorkFactor < TShock.Config.BCryptWorkFactor) @@ -510,7 +512,7 @@ namespace TShockAPI.DB { if (string.IsNullOrEmpty(password) || password == "non-existant password") return null; - return hashPassword(Encoding.UTF8.GetBytes(password)); + return HashPassword(Encoding.UTF8.GetBytes(password)); } }