cothema /
cmsbe-user
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Presenters; |
||
| 4 | |||
| 5 | use Nette; |
||
| 6 | use Cothema\Model\User\User; |
||
| 7 | use Nette\Application\UI\Form; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * |
||
| 11 | * Sign in/out presenters. |
||
| 12 | * |
||
| 13 | * @author Miloš Havlíček <[email protected]> |
||
| 14 | * @property $signInFormSucceeded |
||
| 15 | */ |
||
| 16 | class SignPresenter extends BasePresenter |
||
| 17 | { |
||
| 18 | |||
| 19 | public function __construct() |
||
| 20 | { |
||
| 21 | parent::__construct(); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @return void |
||
| 26 | */ |
||
| 27 | public function renderIn() |
||
| 28 | { |
||
| 29 | if ($this->user->isLoggedIn() && $this->user->isInRole('admin')) { |
||
|
0 ignored issues
–
show
|
|||
| 30 | $params = $this->request->getParameters(); |
||
|
0 ignored issues
–
show
The property
$request is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 31 | if (!empty($params['backSignInUrl'])) { |
||
| 32 | $this->redirectUrl($params['backSignInUrl']); |
||
| 33 | } else { |
||
| 34 | $this->redirect('Homepage:'); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Sign-in form factory. |
||
| 41 | * @return Nette\Application\UI\Form |
||
| 42 | */ |
||
| 43 | protected function createComponentSignInForm() |
||
| 44 | { |
||
| 45 | $form = new Form; |
||
| 46 | $form->addText('username', 'Login:') |
||
| 47 | ->setRequired('Prosím, vložte svůj login.') |
||
|
0 ignored issues
–
show
'Prosím, vložte svůj login.' is of type string, but the function expects a boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 48 | ->getControlPrototype() |
||
| 49 | ->class('form-control'); |
||
| 50 | |||
| 51 | $form->addPassword('password', 'Heslo:') |
||
| 52 | ->setRequired('Prosím, vložte své heslo.') |
||
|
0 ignored issues
–
show
'Prosím, vložte své heslo.' is of type string, but the function expects a boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 53 | ->getControlPrototype() |
||
| 54 | ->class('form-control'); |
||
| 55 | |||
| 56 | $form->addHidden('backSignInUrl', $this->getParameter('backSignInUrl')); |
||
| 57 | |||
| 58 | $form->addCheckbox('remember', 'Zůstat přihlášen'); |
||
| 59 | |||
| 60 | $form->addSubmit('send', 'Přihlásit se') |
||
| 61 | ->getControlPrototype() |
||
| 62 | ->class('btn btn-lg btn-success'); |
||
| 63 | |||
| 64 | $form->onSuccess[] = [$this, 'signInFormSucceeded']; |
||
| 65 | return $form; |
||
| 66 | } |
||
| 67 | |||
| 68 | private function getActiveUserByUsername($username) |
||
| 69 | { |
||
| 70 | $rep = $this->em->getRepository(User::class); |
||
| 71 | $users = $rep->findOneBy(['username' => $username, 'active' => 1]); |
||
| 72 | |||
| 73 | return isset($users) ? $users : null; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * |
||
| 78 | * @param Nette\Application\UI\Form $form |
||
| 79 | * @throws \Exception |
||
| 80 | */ |
||
| 81 | public function signInFormSucceeded($form) |
||
| 82 | { |
||
| 83 | $values = $form->getValues(); |
||
| 84 | |||
| 85 | if ($values->remember) { |
||
| 86 | $this->user->setExpiration('14 days', false); |
||
|
0 ignored issues
–
show
The property
$user is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 87 | } else { |
||
| 88 | $this->user->setExpiration('20 minutes', true); |
||
|
0 ignored issues
–
show
The property
$user is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 89 | } |
||
| 90 | |||
| 91 | try { |
||
| 92 | $user = $this->getActiveUserByUsername($values->username); |
||
| 93 | if (!$user) { |
||
| 94 | throw new \Exception('Uživatel není aktivní nebo neexistuje.'); |
||
| 95 | } |
||
| 96 | |||
| 97 | $this->user->login($user->username, $values->password); |
||
|
0 ignored issues
–
show
The property
$user is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 98 | |||
| 99 | $this->flashMessage( |
||
| 100 | 'Byl/a jste úspěšně přihlášen/a jako "'.$user->username.'"', |
||
| 101 | 'success' |
||
| 102 | ); |
||
| 103 | |||
| 104 | if (!empty($values['backSignInUrl'])) { |
||
| 105 | $redirectToUrl = $values['backSignInUrl']; |
||
| 106 | } else { |
||
| 107 | $this->redirect('Homepage:'); |
||
| 108 | } |
||
| 109 | } catch (Nette\Security\AuthenticationException $e) { |
||
| 110 | $form->addError($e->getMessage()); |
||
| 111 | } catch (\Exception $e) { |
||
| 112 | $form->addError($e->getMessage()); |
||
| 113 | } |
||
| 114 | |||
| 115 | if (!empty($redirectToUrl)) { |
||
| 116 | $this->redirectUrl($redirectToUrl); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return void |
||
| 122 | */ |
||
| 123 | public function actionOut() |
||
| 124 | { |
||
| 125 | $this->user->logout(); |
||
|
0 ignored issues
–
show
The property
$user is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 126 | $this->flashMessage('Uživatel byl úspěšně odhlášen.', 'success'); |
||
| 127 | $this->redirect('in'); |
||
| 128 | } |
||
| 129 | |||
| 130 | } |
||
| 131 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.