Пример #1
0
 public User(NetworkCredential credential)
 {
     Login = credential.UserName.ToLower();
     if (Login.Length > 24 || ValidateLogin() == false) // jeśli login jest dłuższy niż 24 znaki lub zawiera niedozwolone znaki
     {
         throw new InvalidUsernameException();
     }
     PasswordHash = ChecksumProvider.CalculateSHA256(credential.Password.Trim(), Login);
     IsBusy       = false;
     Name         = null;
 }
Пример #2
0
        private void ChangePassword()
        {
            string oldPasswordHash = ChecksumProvider.CalculateSHA256(connection[0], Login);

            if (oldPasswordHash != PasswordHash)
            {
                connection.SendMessage(CommandSet.Error, ErrorMessageID.InvalidPassword);
                return;
            }
            PasswordHash = ChecksumProvider.CalculateSHA256(connection[1], Login);
            lock (ThreadSync.Lock)
            {
                Database.ChangeValue(ID, "Users", "Password", PasswordHash);
            }
            connection.SendMessage(CommandSet.OK);
        }