예제 #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);
        }
예제 #2
0
파일: Account.cs 프로젝트: n4v/mooege
 public Account(DBAccount dbAccount)
     : base(dbAccount.Id)
 {
     this.DBAccount = dbAccount;
     SetFields();
 }
예제 #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);
 }