Conditions | 4 |
Paths | 1 |
Total Lines | 28 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function call(Micro $api) |
||
29 | { |
||
30 | $auth = $api->getService('auth'); |
||
31 | $config = $api->getService('config'); |
||
32 | |||
33 | // to get the payload |
||
34 | $data = $auth->data(); |
||
35 | |||
36 | $api->getDI()->setShared( |
||
37 | 'userData', |
||
38 | function () use ($config, $data) { |
||
39 | $session = new Sessions(); |
||
40 | $request = new Request(); |
||
41 | |||
42 | if (!empty($data) && !empty($data['sessionId'])) { |
||
43 | //user |
||
44 | if (!$user = Users::getByEmail($data['email'])) { |
||
45 | throw new UnauthorizedHttpException('User not found'); |
||
46 | } |
||
47 | |||
48 | return $session->check($user, $data['sessionId'], $request->getClientAddress(), 1); |
||
49 | } else { |
||
50 | throw new UnauthorizedHttpException('User not found'); |
||
51 | } |
||
52 | } |
||
53 | ); |
||
54 | |||
55 | return true; |
||
56 | } |
||
58 |