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\Model; |
||
13 | |||
14 | use Jitamin\Foundation\Database\Model; |
||
15 | use Jitamin\Foundation\Security\Token; |
||
16 | |||
17 | /** |
||
18 | * Remember Me Model. |
||
19 | */ |
||
20 | class RememberMeSessionModel extends Model |
||
21 | { |
||
22 | /** |
||
23 | * SQL table name. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | const TABLE = 'remember_me'; |
||
28 | |||
29 | /** |
||
30 | * Expiration (30 days). |
||
31 | * |
||
32 | * @var int |
||
33 | */ |
||
34 | const EXPIRATION = 2592000; |
||
35 | |||
36 | /** |
||
37 | * Get a remember me record. |
||
38 | * |
||
39 | * @param $token |
||
40 | * @param $sequence |
||
41 | * |
||
42 | * @return mixed |
||
43 | */ |
||
44 | View Code Duplication | public function find($token, $sequence) |
|
0 ignored issues
–
show
|
|||
45 | { |
||
46 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
47 | ->table(self::TABLE) |
||
48 | ->eq('token', $token) |
||
49 | ->eq('sequence', $sequence) |
||
50 | ->gt('expiration', time()) |
||
51 | ->findOne(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get all sessions for a given user. |
||
56 | * |
||
57 | * @param int $user_id User id |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | View Code Duplication | public function getAll($user_id) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
62 | { |
||
63 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
64 | ->table(self::TABLE) |
||
65 | ->eq('user_id', $user_id) |
||
66 | ->desc('date_creation') |
||
67 | ->columns('id', 'ip', 'user_agent', 'date_creation', 'expiration') |
||
68 | ->findAll(); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Create a new RememberMe session. |
||
73 | * |
||
74 | * @param int $user_id User id |
||
75 | * @param string $ip IP Address |
||
76 | * @param string $user_agent User Agent |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | public function create($user_id, $ip, $user_agent) |
||
81 | { |
||
82 | $token = hash('sha256', $user_id.$user_agent.$ip.Token::getToken()); |
||
83 | $sequence = Token::getToken(); |
||
84 | $expiration = time() + self::EXPIRATION; |
||
85 | |||
86 | $this->cleanup($user_id); |
||
87 | |||
88 | $this |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
89 | ->db |
||
90 | ->table(self::TABLE) |
||
91 | ->insert([ |
||
92 | 'user_id' => $user_id, |
||
93 | 'ip' => $ip, |
||
94 | 'user_agent' => $user_agent, |
||
95 | 'token' => $token, |
||
96 | 'sequence' => $sequence, |
||
97 | 'expiration' => $expiration, |
||
98 | 'date_creation' => time(), |
||
99 | ]); |
||
100 | |||
101 | return [ |
||
102 | 'token' => $token, |
||
103 | 'sequence' => $sequence, |
||
104 | 'expiration' => $expiration, |
||
105 | ]; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Remove a session record. |
||
110 | * |
||
111 | * @param int $session_id Session id |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | public function remove($session_id) |
||
116 | { |
||
117 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
118 | ->table(self::TABLE) |
||
119 | ->eq('id', $session_id) |
||
120 | ->remove(); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Remove old sessions for a given user. |
||
125 | * |
||
126 | * @param int $user_id User id |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function cleanup($user_id) |
||
131 | { |
||
132 | return $this->db |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
133 | ->table(self::TABLE) |
||
134 | ->eq('user_id', $user_id) |
||
135 | ->lt('expiration', time()) |
||
136 | ->remove(); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Return a new sequence token and update the database. |
||
141 | * |
||
142 | * @param string $token Session token |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | public function updateSequence($token) |
||
147 | { |
||
148 | $sequence = Token::getToken(); |
||
149 | |||
150 | $this |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\RememberMeSessionModel> . 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. ![]() |
|||
151 | ->db |
||
152 | ->table(self::TABLE) |
||
153 | ->eq('token', $token) |
||
154 | ->update(['sequence' => $sequence]); |
||
155 | |||
156 | return $sequence; |
||
157 | } |
||
158 | } |
||
159 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.