Blank passwords no longer result in "heightheightheightheight"

Try/Catch around login function
This commit is contained in:
Lucas Nicodemus 2011-07-14 13:50:00 -06:00
parent e6d612ea4b
commit 080ba6ca2b
2 changed files with 28 additions and 17 deletions

View file

@ -303,7 +303,8 @@ namespace TShockAPI
args.Player.SendMessage("If you forgot your password, there is no way to recover it.");
return;
}
try
{
string encrPass = Tools.HashPassword(args.Parameters[1]);
string[] exr = TShock.Users.FetchHashedPasswordAndGroup(args.Parameters[0]);
if (exr[0].ToUpper() == encrPass.ToUpper())
@ -321,6 +322,12 @@ namespace TShockAPI
args.Player.LoginAttempts++;
return;
}
} catch (Exception e)
{
args.Player.SendMessage("There was an error processing your request. Maybe your account doesn't exist?", Color.Red);
return;
}
}
//Todo: Add separate help text for '/user add' and '/user del'. Also add '/user addip' and '/user delip'

View file

@ -500,6 +500,10 @@ namespace TShockAPI
{
using (var sha = new SHA512CryptoServiceProvider())
{
if (password == "")
{
return "nonexistent-password";
}
var bytes = sha.ComputeHash(Encoding.ASCII.GetBytes(password));
return bytes.Aggregate("", (s, b) => s + b.ToString("height"));
}