public static void CreateAccount(string[] args) { var email = Command.Read <string>(args, 0); var password = Command.Read <string>(args, 1); if (email != null && password != null) { var salt = new byte[0].GenerateRandomKey(0x20).ToHexString(); var result = DB.Auth.Any <Account>(a => a.Email == email); if (!result) { var srp = new SRP6a(salt); srp.CalculateX(email, password.ToUpper(), false); var account = new Account { Email = email, PasswordVerifier = srp.V.ToHexString(), Salt = salt, Region = Regions.XX, }; if (DB.Auth.Add(account)) { Log.Message(LogType.Normal, "Account {0} successfully created", email); } } else { Log.Message(LogType.Error, "Account {0} already in database", email); } } }
public static void Create(string[] args) { var email = Command.Read <string>(args, 0); var password = Command.Read <string>(args, 1); if (email != null && password != null) { var salt = new byte[0].GenerateRandomKey(0x20).ToHexString(); var result = DB.Auth.Accounts.Any(a => a.Email.Equals(email)); if (!result) { var srp = new SRP6a(salt); srp.CalculateX(email, password.ToUpper(), false); var account = new Account { Email = email, PasswordVerifier = srp.V.ToHexString(), Salt = salt, Expansion = 5 }; if (DB.Auth.Add(account)) { // Default class/expansion data (sent in AuthResponse) var defaultAllowedClasses = new byte[, ] { { 1, 0 }, { 2, 0 }, { 3, 0 }, { 4, 0 }, { 5, 0 }, { 6, 2 }, { 7, 0 }, { 8, 0 }, { 9, 0 }, { 10, 4 }, { 11, 0 } }; // Default race/expansion data (sent in AuthResponse) var defaultAllowedRaces = new byte[, ] { { 1, 0 }, { 2, 0 }, { 3, 0 }, { 4, 0 }, { 5, 0 }, { 6, 0 }, { 7, 0 }, { 8, 0 }, { 9, 3 }, { 10, 1 }, { 11, 1 }, { 22, 3 }, { 24, 4 }, { 25, 4 }, { 26, 4 } }; for (int i = 0; i < defaultAllowedClasses.Length / 2; i++) { DB.Auth.Add(new AllowedClass { AccountId = account.Id, Class = defaultAllowedClasses[i, 0], Expansion = defaultAllowedClasses[i, 1] }); } for (int i = 0; i < defaultAllowedRaces.Length / 2; i++) { DB.Auth.Add(new AllowedRace { AccountId = account.Id, Race = defaultAllowedRaces[i, 0], Expansion = defaultAllowedRaces[i, 1] }); } Log.Message(LogType.Normal, "Account {0} successfully created", email); } } else { Log.Message(LogType.Error, "Account {0} already in database", email); } } }