예제 #1
0
 /** @test */
 public function should_test_equality()
 {
     $one = new Password('qwertyuiop');
     $two = new Password('qwertyuiop');
     $three = new Password('asdfghjkl');
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
예제 #2
0
 /**
  * Check if the given clear-text password matches the temporary password
  * sent by e-mail for password reset operations.
  *
  * @param string $plaintext
  *
  * @return bool True if matches, false otherwise
  */
 public function checkTemporaryPassword($plaintext)
 {
     global $wgNewPasswordExpiry;
     $this->load();
     $this->loadPasswords();
     if ($this->mNewpassword->equals($plaintext)) {
         if (is_null($this->mNewpassTime)) {
             return true;
         }
         $expiry = wfTimestamp(TS_UNIX, $this->mNewpassTime) + $wgNewPasswordExpiry;
         return time() < $expiry;
     } else {
         return false;
     }
 }
 /**
  * @param string $plaintext User-provided password plaintext.
  * @param Password $password Password to check against
  *
  * @return Status
  */
 protected function matchHash($plaintext, Password $password)
 {
     $matched = false;
     if ($password->equals($plaintext)) {
         $matched = true;
     } elseif (!$password instanceof Pbkdf2Password && function_exists('iconv')) {
         // Some wikis were converted from ISO 8859-1 to UTF-8;
         // retained hashes may contain non-latin chars.
         $latin1 = iconv('UTF-8', 'WINDOWS-1252//TRANSLIT', $plaintext);
         if ($password->equals($latin1)) {
             $matched = true;
         }
     }
     if ($matched) {
         return Status::newGood($password);
     } else {
         return Status::newFatal('bad');
     }
 }