예제 #1
0
파일: User.php 프로젝트: gabykode/tf
 /**
  * Authenticate user.
  *
  * If user password needs to be updated, new information will be saved.
  *
  * @param string $password  Plaintext password.
  * @return bool
  */
 public function authenticate($password)
 {
     $save = false;
     // Plain-text is still stored
     if ($this->password) {
         if ($password !== $this->password) {
             // Plain-text passwords do not match, we know we should fail but execute
             // verify to protect us from timing attacks and return false regardless of
             // the result
             Authentication::verify($password, self::getGrav()['config']->get('system.security.default_hash'));
             return false;
         } else {
             // Plain-text does match, we can update the hash and proceed
             $save = true;
             $this->hashed_password = Authentication::create($this->password);
             unset($this->password);
         }
     }
     $result = Authentication::verify($password, $this->hashed_password);
     // Password needs to be updated, save the file.
     if ($result == 2) {
         $save = true;
         $this->hashed_password = Authentication::create($password);
     }
     if ($save) {
         $this->save();
     }
     return (bool) $result;
 }
예제 #2
0
파일: User.php 프로젝트: qbi/datenknoten.me
 /**
  * Authenticate user.
  *
  * If user password needs to be updated, new information will be saved.
  *
  * @param string $password  Plaintext password.
  * @return bool
  */
 public function authenticate($password)
 {
     $result = Authentication::verify($password, $this->password);
     // Password needs to be updated, save the file.
     if ($result == 2) {
         $this->password = Authentication::create($password);
         $this->save();
     }
     return (bool) $result;
 }
예제 #3
0
파일: User.php 프로젝트: nunull/grav
 /**
  * Save user without the username
  */
 public function save()
 {
     $file = $this->file();
     if ($file) {
         // if plain text password, hash it and remove plain text
         if ($this->password) {
             $this->hashed_password = Authentication::create($this->password);
             unset($this->password);
         }
         $username = $this->get('username');
         unset($this->username);
         $file->save($this->items);
         $this->set('username', $username);
     }
 }
예제 #4
0
파일: User.php 프로젝트: dweelie/grav
 /**
  * Save user without the username
  */
 public function save()
 {
     $file = $this->file();
     if ($file) {
         $username = $this->get('username');
         if (!$file->filename()) {
             $locator = Grav::instance()['locator'];
             $file->filename($locator->findResource('account://') . DS . strtolower($username) . YAML_EXT);
         }
         // if plain text password, hash it and remove plain text
         if ($this->password) {
             $this->hashed_password = Authentication::create($this->password);
             unset($this->password);
         }
         unset($this->username);
         $file->save($this->items);
         $this->set('username', $username);
     }
 }