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 | |||
16 | /** |
||
17 | * User Locking Model. |
||
18 | */ |
||
19 | class UserLockingModel extends Model |
||
20 | { |
||
21 | /** |
||
22 | * Get the number of failed login for the user. |
||
23 | * |
||
24 | * @param string $username |
||
25 | * |
||
26 | * @return int |
||
27 | */ |
||
28 | public function getFailedLogin($username) |
||
29 | { |
||
30 | return (int) $this->db->table(UserModel::TABLE) |
||
0 ignored issues
–
show
|
|||
31 | ->eq('username', $username) |
||
32 | ->findOneColumn('nb_failed_login'); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Reset to 0 the counter of failed login. |
||
37 | * |
||
38 | * @param string $username |
||
39 | * |
||
40 | * @return bool |
||
41 | */ |
||
42 | View Code Duplication | public function resetFailedLogin($username) |
|
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. ![]() |
|||
43 | { |
||
44 | return $this->db->table(UserModel::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\UserLockingModel> . 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. ![]() |
|||
45 | ->eq('username', $username) |
||
46 | ->update([ |
||
47 | 'nb_failed_login' => 0, |
||
48 | 'lock_expiration_date' => 0, |
||
49 | ]); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Increment failed login counter. |
||
54 | * |
||
55 | * @param string $username |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function incrementFailedLogin($username) |
||
60 | { |
||
61 | return $this->db->table(UserModel::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\UserLockingModel> . 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. ![]() |
|||
62 | ->eq('username', $username) |
||
63 | ->increment('nb_failed_login', 1); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Check if the account is locked. |
||
68 | * |
||
69 | * @param string $username |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | View Code Duplication | public function isLocked($username) |
|
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. ![]() |
|||
74 | { |
||
75 | return $this->db->table(UserModel::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\UserLockingModel> . 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. ![]() |
|||
76 | ->eq('username', $username) |
||
77 | ->neq('lock_expiration_date', 0) |
||
78 | ->gte('lock_expiration_date', time()) |
||
79 | ->exists(); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * Lock the account for the specified duration. |
||
84 | * |
||
85 | * @param string $username Username |
||
86 | * @param int $duration Duration in minutes |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | View Code Duplication | public function lock($username, $duration = 15) |
|
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. ![]() |
|||
91 | { |
||
92 | return $this->db->table(UserModel::TABLE) |
||
0 ignored issues
–
show
The property
db does not exist on object<Jitamin\Model\UserLockingModel> . 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. ![]() |
|||
93 | ->eq('username', $username) |
||
94 | ->update([ |
||
95 | 'lock_expiration_date' => time() + $duration * 60, |
||
96 | ]); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Return true if the captcha must be shown. |
||
101 | * |
||
102 | * @param string $username |
||
103 | * @param int $tries |
||
104 | * |
||
105 | * @return bool |
||
106 | */ |
||
107 | public function hasCaptcha($username, $tries = BRUTEFORCE_CAPTCHA) |
||
108 | { |
||
109 | return $this->getFailedLogin($username) >= $tries; |
||
110 | } |
||
111 | } |
||
112 |
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.