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 | /* |
||
4 | * This file is part of Jitamin. |
||
5 | * |
||
6 | * Copyright (C) Jitamin Team |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Jitamin\Foundation\Identity; |
||
13 | |||
14 | use Jitamin\Foundation\Base; |
||
15 | use Jitamin\Foundation\Security\Role; |
||
16 | |||
17 | /** |
||
18 | * User Session. |
||
19 | */ |
||
20 | class UserSession extends Base |
||
21 | { |
||
22 | /** |
||
23 | * Refresh current session if necessary. |
||
24 | * |
||
25 | * @param int $user_id |
||
26 | */ |
||
27 | public function refresh($user_id) |
||
28 | { |
||
29 | if ($this->getId() == $user_id) { |
||
30 | $this->initialize($this->userModel->getById($user_id)); |
||
0 ignored issues
–
show
|
|||
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Update user session. |
||
36 | * |
||
37 | * @param array $user |
||
38 | */ |
||
39 | public function initialize(array $user) |
||
40 | { |
||
41 | foreach (['password', 'is_admin', 'is_project_admin', 'twofactor_secret'] as $column) { |
||
42 | if (isset($user[$column])) { |
||
43 | unset($user[$column]); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | $user['id'] = (int) $user['id']; |
||
48 | $user['is_ldap_user'] = isset($user['is_ldap_user']) ? (bool) $user['is_ldap_user'] : false; |
||
49 | $user['twofactor_activated'] = isset($user['twofactor_activated']) ? (bool) $user['twofactor_activated'] : false; |
||
50 | |||
51 | $this->sessionStorage->user = $user; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
52 | $this->sessionStorage->postAuthenticationValidated = false; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Get user properties. |
||
57 | * |
||
58 | * @return array |
||
59 | */ |
||
60 | public function getAll() |
||
61 | { |
||
62 | return $this->sessionStorage->user; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get user application role. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getRole() |
||
71 | { |
||
72 | return $this->sessionStorage->user['role']; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Return true if the user has validated the 2FA key. |
||
77 | * |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isPostAuthenticationValidated() |
||
81 | { |
||
82 | return isset($this->sessionStorage->postAuthenticationValidated) && $this->sessionStorage->postAuthenticationValidated === true; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Validate 2FA for the current session. |
||
87 | */ |
||
88 | public function validatePostAuthentication() |
||
89 | { |
||
90 | $this->sessionStorage->postAuthenticationValidated = true; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Return true if the user has 2FA enabled. |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | public function hasPostAuthentication() |
||
99 | { |
||
100 | return isset($this->sessionStorage->user['twofactor_activated']) && $this->sessionStorage->user['twofactor_activated'] === true; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Disable 2FA for the current session. |
||
105 | */ |
||
106 | public function disablePostAuthentication() |
||
107 | { |
||
108 | $this->sessionStorage->user['twofactor_activated'] = false; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Return true if the logged user is admin. |
||
113 | * |
||
114 | * @return bool |
||
115 | */ |
||
116 | public function isAdmin() |
||
117 | { |
||
118 | return isset($this->sessionStorage->user['role']) && $this->sessionStorage->user['role'] === Role::APP_ADMIN; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
119 | } |
||
120 | |||
121 | /** |
||
122 | * Get the connected user id. |
||
123 | * |
||
124 | * @return int |
||
125 | */ |
||
126 | public function getId() |
||
127 | { |
||
128 | return isset($this->sessionStorage->user['id']) ? (int) $this->sessionStorage->user['id'] : 0; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Get username. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | public function getUsername() |
||
137 | { |
||
138 | return isset($this->sessionStorage->user['username']) ? $this->sessionStorage->user['username'] : ''; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Check is the user is connected. |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isLogged() |
||
147 | { |
||
148 | return isset($this->sessionStorage->user) && !empty($this->sessionStorage->user); |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
149 | } |
||
150 | |||
151 | /** |
||
152 | * Get project filters from the session. |
||
153 | * |
||
154 | * @param int $project_id |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | public function getFilters($project_id) |
||
159 | { |
||
160 | return !empty($this->sessionStorage->filters[$project_id]) ? $this->sessionStorage->filters[$project_id] : 'status:open'; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Save project filters in the session. |
||
165 | * |
||
166 | * @param int $project_id |
||
167 | * @param string $filters |
||
168 | */ |
||
169 | public function setFilters($project_id, $filters) |
||
170 | { |
||
171 | $this->sessionStorage->filters[$project_id] = $filters; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Get recent projects from the session. |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | public function getRecentProjects() |
||
180 | { |
||
181 | return isset($this->sessionStorage->recentProjectIds) && !empty($this->sessionStorage->recentProjectIds) ? $this->sessionStorage->recentProjectIds : []; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
182 | } |
||
183 | |||
184 | /** |
||
185 | * Save recent project in the session. |
||
186 | * |
||
187 | * @param int $project_id |
||
188 | * @param string $filters |
||
0 ignored issues
–
show
There is no parameter named
$filters . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
189 | */ |
||
190 | public function setRecentProject($project_id) |
||
191 | { |
||
192 | if (!isset($this->sessionStorage->recentProjectIds)) { |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
193 | $this->sessionStorage->recentProjectIds = []; |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
194 | } |
||
195 | |||
196 | array_unshift($this->sessionStorage->recentProjectIds, $project_id); |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
197 | |||
198 | $this->sessionStorage->recentProjectIds = array_slice(array_unique($this->sessionStorage->recentProjectIds), 0, 5); |
||
0 ignored issues
–
show
The property
sessionStorage does not exist on object<Jitamin\Foundation\Identity\UserSession> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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.");
}
}
}
If the property has read access only, you can use the @property-read 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. ![]() |
|||
199 | } |
||
200 | } |
||
201 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read 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.