Example #1
0
 public function delete()
 {
     $hash = $this->session->getHash();
     if (false !== ($session = $this->userSessions->findOneByHash($hash))) {
         $session->delete();
     }
 }
Example #2
0
 /**
  * @param string $name service identifier
  * @param \Janeiro\Di\Container $container
  */
 public function register($name, Container $container)
 {
     $session = new Session(hash('MD5', uniqid('', true)));
     if (isset($_SERVER[self::HEADER_SESSION_HASH])) {
         $hash = $_SERVER[self::HEADER_SESSION_HASH];
         if (preg_match(self::MATCH_MD5, $hash)) {
             $session->setHash($hash)->start();
         }
     }
     $container->set($name, $session);
 }
 /**
  * Validate login credentials
  *
  * @param string $username
  * @param string $password
  * @return bool
  */
 public function validate($username, $password)
 {
     $success = false;
     $this->users->select([['column' => 'username', 'value' => $username], ['column' => 'deleted', 'value' => false]]);
     if (count($this->users) === 1) {
         /** @var \Core\Persistence\Entity\User $user */
         $user = $this->users->current();
         if ($password === hash('SHA512', $user->getPassword() . $this->session->getHash())) {
             $success = true;
         }
     }
     return $success;
 }
Example #4
0
 /**
  * @param \Janeiro\Request\AbstractRequest
  * @template Index.phtml
  * @return string
  */
 public function indexAction(AbstractRequest $request)
 {
     $this->view->set('locale', $request->getLanguage());
     $this->view->set('hash', $this->session->getHash());
     return $this->view->render();
 }