Exemplo n.º 1
0
 public function startup()
 {
     parent::startup();
     if (!$this->user->isLoggedIn()) {
         $this->redirect(':Sign:in');
     }
     $this->identity = $this->user->identity;
     $this->userEntity = $this->userService->get($this->identity->id);
     $this->navigation = new NavigationCollection($this->translator);
     $this->template->navigation = $this->navigation;
     $this->template->systemName = systemName;
     $this->template->author = $this->userEntity->getEmail();
 }
Exemplo n.º 2
0
 /**
  * Performs an authentication against e.g. database.
  * and returns IIdentity on success or throws AuthenticationException
  * @return IIdentity
  * @throws AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $row = $this->userService->getByEmail($email);
     if (!$row) {
         throw new AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
     } elseif (!Passwords::verify($password, $row->password)) {
         throw new AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
     } elseif (Passwords::needsRehash($row->password)) {
         $this->userService->edit(['password' => Passwords::hash($password)], ['email' => $email]);
     }
     $row->password = null;
     $this->onSignIn($row->email);
     return new Identity($row->idUser, null, []);
     //TODO: přenášet informace o uživateli?
 }