| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4.074 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | 1 | public function login($email, $pass) |
|
| 30 | { |
||
| 31 | 1 | if ($this->isLoggedIn()) { |
|
| 32 | return; |
||
| 33 | } |
||
| 34 | |||
| 35 | 1 | $user = $this->db |
|
| 36 | 1 | ->connect() |
|
| 37 | 1 | ->select("email, id, password") |
|
| 38 | 1 | ->from("User") |
|
| 39 | 1 | ->where("email='$email'") |
|
| 40 | 1 | ->execute() |
|
| 41 | 1 | ->fetch(); |
|
| 42 | |||
| 43 | 1 | if (!$user) { |
|
| 44 | return false; |
||
| 45 | } |
||
| 46 | |||
| 47 | 1 | $passCheck = password_verify($pass, $user->password); |
|
| 48 | |||
| 49 | 1 | if ($passCheck) { |
|
| 50 | 1 | $this->di->get("session")->set("user", $user->email); |
|
| 51 | 1 | $this->di->get("session")->set("userId", $user->id); |
|
| 52 | 1 | return true; |
|
| 53 | } |
||
| 54 | |||
| 55 | // var_dump($this->di->get("session")->get("user")); |
||
| 56 | return false; |
||
| 57 | } |
||
| 70 |