Example #1
0
 /**
  * Resolve credentials
  *
  *
  * That is, each line consists of the user's username, the applicable
  * authentication realm, and the password or hash, each delimited by
  * colons.
  *
  * @param  string $email Username
  * @param  string $realm    Authentication Realm
  * @return Result  Authentication result
  * 
  */
 public function resolve($email, $realm, $password = null)
 {
     if (empty($email)) {
         return new Result(Result::FAILURE);
     }
     // Open file, read through looking for matching credentials
     ErrorHandler::start(E_WARNING);
     $rep = $this->em->getRepository($this->entityClass);
     $user = $rep->findOneBy(['email' => $email]);
     if ($user) {
         $authenticated = \Aaa\Service\AaaService::checkPassword($user, $password);
         if ($authenticated) {
             return new Result(Result::SUCCESS, $user);
         }
     }
     return new Result(Result::FAILURE, null);
 }
Example #2
0
 /**
  * zamenja geslo uporabniku
  * @params string $oldPassword
  * @params string $newPassword
  * @param $oldPassword
  * @param $newPassword
  * @return true če geslo uspešno menjano,
  * @throws MaxException
  */
 public function changePassword($oldPassword, $newPassword)
 {
     /**
      * ali uporabnik prijavljen
      */
     $ident = $this->getIdentity();
     if (!$ident) {
         throw new MaxException('Uporabnik ni prijavljen', 1000995);
     }
     /**
      * ali novo geslo različno staremu?
      */
     if ($newPassword == $oldPassword) {
         throw new MaxException('Novo geslo enako staremu', 1000993);
     }
     /**
      * preverimo staro geslo
      */
     $staroGesloOk = \Aaa\Service\AaaService::checkPassword($ident, $oldPassword);
     if (!$staroGesloOk) {
         throw new MaxException('Napačno staro geslo', 1000994);
     }
     /**
      * zamenjamo geslo
      */
     $ident->setPassword($newPassword);
     $this->getEm()->flush();
     return TRUE;
 }