Conditions | 5 |
Paths | 7 |
Total Lines | 29 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
24 | public function authenticate() |
||
25 | { |
||
26 | // Try to match the user based on both the plain-text password and a |
||
27 | // hashed varient. The default "admin" user has its password stored in |
||
28 | // plaintext so we need to hash it on first login. |
||
29 | |||
30 | // Match usernames case-insensitively |
||
31 | $user = User::model()->find('LOWER(username) = :username', array( |
||
32 | ':username'=>strtolower($this->username))); |
||
33 | |||
34 | $this->errorCode = self::ERROR_UNKNOWN_IDENTITY; |
||
35 | |||
36 | if ($user !== null) |
||
37 | { |
||
38 | // Password is stored as plain-text |
||
39 | if ($user->password === $this->password) |
||
40 | { |
||
41 | // Re-save the user, that way the password will get hashed |
||
42 | $user->save(); |
||
43 | $this->errorCode = self::ERROR_NONE; |
||
44 | } |
||
45 | elseif (User::checkPassword($this->password, $user->password)) |
||
46 | $this->errorCode = self::ERROR_NONE; |
||
47 | |||
48 | if ($this->errorCode === self::ERROR_NONE) |
||
49 | $this->_userId = $user->id; |
||
50 | } |
||
51 | |||
52 | return $this->errorCode; |
||
|
|||
53 | } |
||
64 | } |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: