Total Complexity | 9 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class Auth0 |
||
7 | { |
||
8 | public $auth0; |
||
9 | |||
10 | public function __construct() |
||
11 | { |
||
12 | $this->auth0 = new Auth0SDK([ |
||
13 | 'domain' => GJC_AUTH0_DOMAIN, |
||
14 | 'client_id' => GJC_AUTH0_CLIENT_ID, |
||
15 | 'client_secret' => GJC_AUTH0_CLIENT_SECRET, |
||
16 | 'redirect_uri' => GJC_AUTH0_CALLBACK_URL, |
||
17 | 'audience' => GJC_AUTH0_AUDIENCE, |
||
18 | 'scope' => GJC_AUTH0_SCOPE, |
||
19 | 'persist_id_token' => GJC_AUTH0_PER_ID_TOKEN, |
||
20 | 'persist_access_token' => GJC_AUTH0_PER_ACCESS_TOKEN, |
||
21 | 'persist_refresh_token' => GJC_AUTH0_PER_REFRESH_TOKEN, |
||
22 | ]); |
||
23 | } |
||
24 | |||
25 | public function check() |
||
26 | { |
||
27 | $user_info = $this->auth0->getUser(); |
||
28 | |||
29 | if (!$user_info) { |
||
30 | |||
31 | header("Location: " . GJC_AUTH0_LOGIN_URL); |
||
32 | exit; |
||
33 | |||
34 | } else { |
||
35 | |||
36 | return $user_info; |
||
37 | |||
38 | } |
||
39 | |||
40 | } |
||
41 | |||
42 | public function errorCheck($error, $message) |
||
43 | { |
||
44 | if (isset($error) && $error != '') { |
||
45 | echo 'Error: ' . $message; |
||
46 | exit; |
||
47 | } |
||
48 | return; |
||
49 | } |
||
50 | |||
51 | public function login() |
||
54 | } |
||
55 | |||
56 | public function getUser() |
||
57 | { |
||
58 | return $this->auth0->getUser(); |
||
59 | } |
||
60 | |||
61 | public function logout() |
||
67 | } |
||
68 | |||
69 | } |
||
70 |