Example #1
0
 /**
  * @param array $credentials
  * @return Identity
  * @throws \Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $user = $this->userFacade->getByEmail($email);
     if (!$user) {
         throw new NS\AuthenticationException("Email '{$email}' not found.", self::IDENTITY_NOT_FOUND);
     }
     if ($user->password !== $this->calculateHash($password, $user->password)) {
         throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
     }
     return new Identity($user);
 }
Example #2
0
 /**
  * @param $id
  */
 public function actionEdit($id = null)
 {
     if ($id === null) {
         $id = $this->getUser()->getId();
     }
     if (!$this->getUser()->isAllowed('Admin:User', 'editAnother')) {
         if (!($this->user = $this->userFacade->getOne($id))) {
             $this->flashMessage('User does not exist or you dont have permission');
             $this->redirect('Dashboard:');
         }
     }
     $this->user = $this->userFacade->getOne($id);
     $this->template->user = $this->user;
 }
Example #3
0
 /**
  * @return \Flame\CMS\UserBundle\Model\User
  */
 public function getModel()
 {
     return $this->userFacade->getOne($this->getId());
 }