Rev 1086 | Rev 1130 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1086 | Rev 1116 | ||
---|---|---|---|
Line 23... | Line 23... | ||
23 | \defined('INSIDE_OIDPLUS') or die; |
23 | \defined('INSIDE_OIDPLUS') or die; |
24 | // phpcs:enable PSR1.Files.SideEffects |
24 | // phpcs:enable PSR1.Files.SideEffects |
25 | 25 | ||
26 | class OIDplusPagePublicLoginGoogle extends OIDplusPagePluginPublic { |
26 | class OIDplusPagePublicLoginGoogle extends OIDplusPagePluginPublic { |
27 | 27 | ||
- | 28 | /** |
|
- | 29 | * @param string $actionID |
|
- | 30 | * @param array $params |
|
- | 31 | * @return array |
|
- | 32 | * @throws OIDplusException |
|
- | 33 | */ |
|
28 | public function action($actionID, $params) { |
34 | public function action(string $actionID, array $params): array { |
29 | throw new OIDplusException(_L('Unknown action ID')); |
35 | return parent::action($actionID, $params); |
30 | } |
36 | } |
31 | 37 | ||
- | 38 | /** |
|
- | 39 | * @param bool $html |
|
- | 40 | * @return void |
|
- | 41 | */ |
|
32 | public function init($html=true) { |
42 | public function init(bool $html=true) { |
33 | // Nothing |
43 | // Nothing |
34 | } |
44 | } |
35 | 45 | ||
- | 46 | /** |
|
- | 47 | * @param string $id |
|
- | 48 | * @param array $out |
|
- | 49 | * @param bool $handled |
|
- | 50 | * @return void |
|
- | 51 | * @throws OIDplusException |
|
- | 52 | */ |
|
36 | public function gui($id, &$out, &$handled) { |
53 | public function gui(string $id, array &$out, bool &$handled) { |
37 | if ($id === 'oidplus:login_google') { |
54 | if ($id === 'oidplus:login_google') { |
38 | $handled = true; |
55 | $handled = true; |
39 | $out['title'] = _L('Login using Google'); |
56 | $out['title'] = _L('Login using Google'); |
40 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
57 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
41 | 58 | ||
Line 54... | Line 71... | ||
54 | "state=".urlencode($_COOKIE['csrf_token_weak']); |
71 | "state=".urlencode($_COOKIE['csrf_token_weak']); |
55 | $out['text'] = '<p>'._L('Please wait...').'</p><script>window.location.href = '.js_escape($target).';</script>'; |
72 | $out['text'] = '<p>'._L('Please wait...').'</p><script>window.location.href = '.js_escape($target).';</script>'; |
56 | } |
73 | } |
57 | } |
74 | } |
58 | 75 | ||
- | 76 | /** |
|
- | 77 | * @param array $out |
|
- | 78 | * @return void |
|
- | 79 | */ |
|
59 | public function publicSitemap(&$out) { |
80 | public function publicSitemap(array &$out) { |
60 | $out[] = 'oidplus:login_google'; |
81 | $out[] = 'oidplus:login_google'; |
61 | } |
82 | } |
62 | 83 | ||
- | 84 | /** |
|
- | 85 | * @param array $json |
|
- | 86 | * @param string|null $ra_email |
|
- | 87 | * @param bool $nonjs |
|
- | 88 | * @param string $req_goto |
|
- | 89 | * @return bool |
|
- | 90 | */ |
|
63 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
91 | public function tree(array &$json, string $ra_email=null, bool $nonjs=false, string $req_goto=''): bool { |
64 | return true; |
92 | return true; |
65 | } |
93 | } |
66 | 94 | ||
- | 95 | /** |
|
- | 96 | * @param string $request |
|
- | 97 | * @return array|false |
|
- | 98 | */ |
|
67 | public function tree_search($request) { |
99 | public function tree_search(string $request) { |
68 | return false; |
100 | return false; |
69 | } |
101 | } |
70 | 102 | ||
- | 103 | /** |
|
- | 104 | * @param string $id |
|
- | 105 | * @return bool |
|
- | 106 | */ |
|
71 | public function implementsFeature($id) { |
107 | public function implementsFeature(string $id): bool { |
72 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.5') return true; // alternativeLoginMethods() |
108 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.5') return true; // alternativeLoginMethods() |
73 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications() |
109 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications() |
74 | return false; |
110 | return false; |
75 | } |
111 | } |
76 | 112 | ||
- | 113 | /** |
|
- | 114 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.5 |
|
- | 115 | * @return array |
|
- | 116 | * @throws OIDplusException |
|
- | 117 | */ |
|
77 | public function alternativeLoginMethods() { |
118 | public function alternativeLoginMethods() { |
78 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.5 |
- | |
79 | $logins = array(); |
119 | $logins = array(); |
80 | if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) { |
120 | if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) { |
81 | $logins[] = array( |
121 | $logins[] = array( |
82 | 'oidplus:login_google', |
122 | 'oidplus:login_google', |
83 | _L('Login using Google'), |
123 | _L('Login using Google'), |
Line 85... | Line 125... | ||
85 | ); |
125 | ); |
86 | } |
126 | } |
87 | return $logins; |
127 | return $logins; |
88 | } |
128 | } |
89 | 129 | ||
- | 130 | /** |
|
- | 131 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
|
- | 132 | * @param $user |
|
- | 133 | * @return array |
|
- | 134 | * @throws OIDplusException |
|
- | 135 | */ |
|
90 | public function getNotifications($user=null): array { |
136 | public function getNotifications($user=null): array { |
91 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
- | |
92 | $notifications = array(); |
137 | $notifications = array(); |
93 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
138 | if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) { |
94 | if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) { |
139 | if (OIDplus::baseConfig()->getValue('GOOGLE_OAUTH2_ENABLED', false)) { |
95 | if (!function_exists('curl_init')) { |
140 | if (!function_exists('curl_init')) { |
96 | $title = _L('Google OAuth Login'); |
141 | $title = _L('Google OAuth Login'); |