Beispiel #1
0
        private bool ChangePasswordUnsafe(string username, byte[] oldPassword, byte[] newPassword)
        {
            AccountData account = GetAccount(username);

            if (account == null)
            {
                return(false);
            }

            if (!ValidateHash(account, oldPassword))
            {
                return(false);
            }

            AccountCreationData creationData = new AccountCreationData(username, newPassword, GetAccount(username).AccessLevel, account.Contact);

            ReplaceAccountUnsafe(creationData);
            return(true);
        }
Beispiel #2
0
        private bool AddAccountUnsafe(AccountCreationData creationData)
        {
            if (creationData.Username.Length <= 0 || !IsStringAllowed(creationData.Username) || !IsStringAllowed(creationData.Contact))
            {
                return(false);
            }

            if (IsAccountExisting(creationData.Username, creationData.Contact))
            {
                return(false);
            }

            byte[] salt = GenerateSalt(SaltLength);

            return(AddUserData(new AccountData(
                                   creationData.Username,
                                   HashAlgorithm.Hash(creationData.Password, salt, Difficulty),
                                   salt,
                                   Difficulty,
                                   creationData.AccessLevel,
                                   creationData.Contact)));
        }
Beispiel #3
0
 private void ReplaceAccountUnsafe(AccountCreationData creationData)
 {
     EraseAccountUnsafe(creationData.Username);
     AddAccountUnsafe(creationData);
 }
Beispiel #4
0
 public void ReplaceAccount(AccountCreationData creationData)
 {
     m_lock.Execute(() => ReplaceAccountUnsafe(creationData));
 }
Beispiel #5
0
 public bool AddAccount(AccountCreationData creationData)
 {
     return(m_lock.Execute(() => AddAccountUnsafe(creationData)));
 }