Register command no longer has a username param.

Password checking fixed.
This commit is contained in:
Zidonuke 2011-12-29 00:14:57 -05:00
parent 8523df9308
commit 1671db928b
2 changed files with 12 additions and 18 deletions

View file

@ -427,16 +427,17 @@ namespace TShockAPI
{ {
try try
{ {
if (args.Parameters.Count == 2) if (args.Parameters.Count == 1)
{ {
var user = new User(); var user = new User();
user.Name = args.Parameters[0]; user.Name = args.Player.Name;
user.Password = args.Parameters[1]; user.Password = args.Parameters[0];
user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB. user.Group = TShock.Config.DefaultRegistrationGroupName; // FIXME -- we should get this from the DB.
if (TShock.Users.GetUserByName(user.Name) == null) // Cheap way of checking for existance of a user if (TShock.Users.GetUserByName(user.Name) == null) // Cheap way of checking for existance of a user
{ {
args.Player.SendMessage("Account " + user.Name + " has been registered.", Color.Green); args.Player.SendMessage("Account " + user.Name + " has been registered.", Color.Green);
args.Player.SendMessage("Your password is " + user.Password);
TShock.Users.AddUser(user); TShock.Users.AddUser(user);
Log.ConsoleInfo(args.Player.Name + " registered an Account: " + user.Name); Log.ConsoleInfo(args.Player.Name + " registered an Account: " + user.Name);
} }
@ -449,7 +450,7 @@ namespace TShockAPI
} }
else else
{ {
args.Player.SendMessage("Invalid syntax! Proper syntax: /register <username> <password>", Color.Red); args.Player.SendMessage("Invalid syntax! Proper syntax: /register <password>", Color.Red);
} }
} }
catch (UserManagerException ex) catch (UserManagerException ex)

View file

@ -303,18 +303,14 @@ namespace TShockAPI
args.Player.PlayerData.CopyInventory(args.Player); args.Player.PlayerData.CopyInventory(args.Player);
TShock.InventoryDB.InsertPlayerData(args.Player); TShock.InventoryDB.InsertPlayerData(args.Player);
args.Player.SendMessage("Authenticated as " + args.Player + " successfully.", Color.LimeGreen); args.Player.SendMessage("Authenticated as " + args.Player.Name + " successfully.", Color.LimeGreen);
Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user: " + args.Player); Log.ConsoleInfo(args.Player.Name + " authenticated successfully as user: " + args.Player.Name);
return true;
}
else
{
TShock.Utils.ForceKick(args.Player, "Incorrect Account Password, use the password you created with /register");
return true; return true;
} }
TShock.Utils.ForceKick(args.Player, "Incorrect User Account Password");
return true;
} }
else if (!string.IsNullOrEmpty(TShock.Config.ServerPassword)) if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
{ {
if(TShock.Config.ServerPassword == password) if(TShock.Config.ServerPassword == password)
{ {
@ -324,11 +320,8 @@ namespace TShockAPI
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index); NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
return true; return true;
} }
else TShock.Utils.ForceKick(args.Player, "Incorrect Server Password");
{ return true;
TShock.Utils.ForceKick(args.Player, "Incorrect Server Password");
return true;
}
} }
TShock.Utils.ForceKick(args.Player, "Bad Password Attempt"); TShock.Utils.ForceKick(args.Player, "Bad Password Attempt");