public static void CreateAccount(CommandArgs args)
{
var email = args.Read<string>();
var password = args.Read<string>();
if (email != null && password != null)
{
var salt = new byte[0].GenerateRandomKey(32).ToHexString();
// Check if account exists.
if (!Database.Bnet.Any<Account>(a => a.Email == email))
{
var account = new Account
{
Email = email,
PasswordVerifier = PasswordHash.GeneratePasswordVerifier(email, password, salt).ToHexString(),
Salt = salt,
// Region = XX
Region = 7
};
var gameAccount = new GameAccount
{
AccountId = Database.Bnet.GetAutoIncrementValue<Account, uint>(),
Game = "WoW",
Index = 1,
// Region = XX
Region = 7,
ExpansionLevel = 6
};
if (Database.Bnet.Add(account) && Database.Bnet.Add(gameAccount))
Log.Message(LogTypes.Success, $"Account '{email}' successfully created.");
else
Log.Message(LogTypes.Error, $"Account creation failed.");
}
else
Log.Message(LogTypes.Error, $"Account '{email}' already in database.");
}
}