示例#1
0
 /**
  * {@inheritdoc}
  */
 public function isMember(UserInterface $user)
 {
     if (!$this->exists) {
         throw new LogicException(vsprintf("%s(): You can only check if a user is a member of a group that exist in the database.", [__METHOD__]));
     }
     return $this->users()->where($user->getPrimaryKey(), '=', $user->getPrimaryKeyValue())->count() > 0;
 }
 /**
  * {@inheritdoc}
  */
 public function validatePassword(UserInterface $user, $password)
 {
     $hash = $user->getPassword();
     // Check if the provided password is valid
     $isValid = Password::validate($password, $hash);
     // Check if the password needs to be rehashed IF the provided password is valid
     if ($isValid && Password::needsRehash($hash)) {
         $user->setPassword($password);
         $user->save();
     }
     // Return validation result
     return $isValid;
 }
示例#3
0
 /**
  * Validates a user password.
  *
  * @access  public
  * @param   \mako\auth\user\UserInterface  $user      User object
  * @param   string                         $password  Password
  * @return  boolean
  */
 public function validatePassword(UserInterface $user, $password)
 {
     return Password::validate($password, $user->getPassword());
 }