| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function isAuthorized($user) |
||
| 17 | { |
||
| 18 | $session = $this->request->clientIp() . $this->request->header('User-Agent') . gethostbyaddr($this->request->clientIp()); |
||
| 19 | |||
| 20 | $this->UsersTwoFactorAuth = TableRegistry::get('UsersTwoFactorAuth'); |
||
|
|
|||
| 21 | |||
| 22 | $tfa = $this->UsersTwoFactorAuth |
||
| 23 | ->find() |
||
| 24 | ->where([ |
||
| 25 | 'user_id' => $user |
||
| 26 | ]) |
||
| 27 | ->first(); |
||
| 28 | |||
| 29 | if (is_null($tfa)) { |
||
| 30 | return false; |
||
| 31 | } |
||
| 32 | |||
| 33 | return $tfa->session === $session; |
||
| 34 | } |
||
| 35 | } |
||
| 36 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: