Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 public Account(DBAccount dbAccount)
     : base(dbAccount.Id)
 {
     this.DBAccount = dbAccount;
     SetFields();
 }
Ejemplo n.º 3
0
 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);
 }