public static Account CreateAccount(string email, string password, string battleTag, Account.UserLevels userLevel = Account.UserLevels.User) { if (password.Length > 16) password = password.Substring(0, 16); // make sure the password does not exceed 16 chars. var hashCode = GetRandomHashCodeForBattleTag(); var salt = SRP6a.GetRandomBytes(32); var passwordVerifier = SRP6a.CalculatePasswordVerifierForAccount(email, password, salt); var newDBAccount = new DBAccount { Email = email, Salt = salt, PasswordVerifier = passwordVerifier, BattleTagName = battleTag, UserLevel = userLevel, HashCode = hashCode }; DBSessions.AccountSession.SaveOrUpdate(newDBAccount); DBSessions.AccountSession.Flush(); return GetAccountByDBAccount(newDBAccount); }
public Account(DBAccount dbAccount) : base(dbAccount.Id) { this.DBAccount = dbAccount; SetFields(); }
public static Account GetAccountByDBAccount(DBAccount dbAccount) { if (!LoadedAccounts.Any(acc => acc.DBAccount.Id == dbAccount.Id)) LoadedAccounts.Add(new Account(dbAccount)); return LoadedAccounts.Single(acc => acc.DBAccount.Id == dbAccount.Id); }