Made sure /register checks for an existing user account before adding the user.
This commit is contained in:
parent
98c139584e
commit
fab469c35f
1 changed files with 12 additions and 3 deletions
|
|
@ -378,11 +378,20 @@ namespace TShockAPI
|
||||||
user.Password = args.Parameters[1];
|
user.Password = args.Parameters[1];
|
||||||
user.Group = "default"; // FIXME -- we should get this from the DB.
|
user.Group = "default"; // FIXME -- we should get this from the DB.
|
||||||
|
|
||||||
|
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);
|
||||||
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);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("Account " + user.Name + " has already been registered.", Color.Red);
|
||||||
|
Log.ConsoleInfo(args.Player.Name + " failed to register an existing Account: " + user.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
args.Player.SendMessage("Invalid syntax! Proper syntax: /register <username> <password>", Color.Red);
|
args.Player.SendMessage("Invalid syntax! Proper syntax: /register <username> <password>", Color.Red);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue