Blank passwords no longer result in "heightheightheightheight"
Try/Catch around login function
This commit is contained in:
parent
e6d612ea4b
commit
080ba6ca2b
2 changed files with 28 additions and 17 deletions
|
|
@ -303,7 +303,8 @@ namespace TShockAPI
|
||||||
args.Player.SendMessage("If you forgot your password, there is no way to recover it.");
|
args.Player.SendMessage("If you forgot your password, there is no way to recover it.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
string encrPass = Tools.HashPassword(args.Parameters[1]);
|
string encrPass = Tools.HashPassword(args.Parameters[1]);
|
||||||
string[] exr = TShock.Users.FetchHashedPasswordAndGroup(args.Parameters[0]);
|
string[] exr = TShock.Users.FetchHashedPasswordAndGroup(args.Parameters[0]);
|
||||||
if (exr[0].ToUpper() == encrPass.ToUpper())
|
if (exr[0].ToUpper() == encrPass.ToUpper())
|
||||||
|
|
@ -321,6 +322,12 @@ namespace TShockAPI
|
||||||
args.Player.LoginAttempts++;
|
args.Player.LoginAttempts++;
|
||||||
return;
|
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'
|
//Todo: Add separate help text for '/user add' and '/user del'. Also add '/user addip' and '/user delip'
|
||||||
|
|
|
||||||
|
|
@ -500,6 +500,10 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
using (var sha = new SHA512CryptoServiceProvider())
|
using (var sha = new SHA512CryptoServiceProvider())
|
||||||
{
|
{
|
||||||
|
if (password == "")
|
||||||
|
{
|
||||||
|
return "nonexistent-password";
|
||||||
|
}
|
||||||
var bytes = sha.ComputeHash(Encoding.ASCII.GetBytes(password));
|
var bytes = sha.ComputeHash(Encoding.ASCII.GetBytes(password));
|
||||||
return bytes.Aggregate("", (s, b) => s + b.ToString("height"));
|
return bytes.Aggregate("", (s, b) => s + b.ToString("height"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue