Rev 1288 | Rev 1305 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1288 | Rev 1293 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | // phpcs:enable PSR1.Files.SideEffects |
24 | // phpcs:enable PSR1.Files.SideEffects |
25 | 25 | ||
26 | class OIDplusPagePublicLogin extends OIDplusPagePluginPublic { |
26 | class OIDplusPagePublicLogin extends OIDplusPagePluginPublic { |
27 | 27 | ||
28 | /** |
28 | /** |
29 | * @param string $actionID |
- | |
30 | * @param array $params |
29 | * @param array $params |
31 | * @return array |
30 | * @return array |
32 | * @throws OIDplusException |
31 | * @throws OIDplusException |
33 | */ |
32 | */ |
34 | public function action(string $actionID, array $params): array { |
33 | private function action_RaLogin(array $params): array { |
35 | // === RA LOGIN/LOGOUT === |
- | |
36 | - | ||
37 | if ($actionID == 'ra_login') { |
- | |
38 | OIDplus::getActiveCaptchaPlugin()->captchaVerify($params, 'captcha'); |
34 | OIDplus::getActiveCaptchaPlugin()->captchaVerify($params, 'captcha'); |
39 | 35 | ||
40 | _CheckParamExists($params, 'email'); |
36 | _CheckParamExists($params, 'email'); |
41 | _CheckParamExists($params, 'password'); |
37 | _CheckParamExists($params, 'password'); |
42 | 38 | ||
Line 70... | Line 66... | ||
70 | OIDplus::logger()->log("V2:[WARN]A", "Failed login to RA account '%1' (RA not existing)", $email); |
66 | OIDplus::logger()->log("V2:[WARN]A", "Failed login to RA account '%1' (RA not existing)", $email); |
71 | } |
67 | } |
72 | } |
68 | } |
73 | throw new OIDplusException(_L('Wrong password or user not registered')); |
69 | throw new OIDplusException(_L('Wrong password or user not registered')); |
74 | } |
70 | } |
- | 71 | } |
|
75 | 72 | ||
- | 73 | /** |
|
- | 74 | * @param array $params |
|
- | 75 | * @return array |
|
76 | } else if ($actionID == 'ra_logout') { |
76 | * @throws OIDplusException |
77 | 77 | */ |
|
- | 78 | private function action_RaLogout(array $params): array { |
|
78 | _CheckParamExists($params, 'email'); |
79 | _CheckParamExists($params, 'email'); |
79 | 80 | ||
80 | $email = $params['email']; |
81 | $email = $params['email']; |
81 | 82 | ||
82 | OIDplus::authUtils()->raLogoutEx($email); |
83 | OIDplus::authUtils()->raLogoutEx($email); |
83 | 84 | ||
84 | return array("status" => 0); |
85 | return array("status" => 0); |
85 | } |
86 | } |
86 | 87 | ||
- | 88 | /** |
|
- | 89 | * @param array $params |
|
- | 90 | * @return array |
|
87 | // === ADMIN LOGIN/LOGOUT === |
91 | * @throws OIDplusException |
88 | 92 | */ |
|
89 | else if ($actionID == 'admin_login') { |
93 | private function action_AdminLogin(array $params): array { |
90 | OIDplus::getActiveCaptchaPlugin()->captchaVerify($params, 'captcha'); |
94 | OIDplus::getActiveCaptchaPlugin()->captchaVerify($params, 'captcha'); |
91 | 95 | ||
92 | _CheckParamExists($params, 'password'); |
96 | _CheckParamExists($params, 'password'); |
93 | if (OIDplus::authUtils()->adminCheckPassword($params['password'])) { |
97 | if (OIDplus::authUtils()->adminCheckPassword($params['password'])) { |
94 | $remember_me = isset($params['remember_me']) && ($params['remember_me']); |
98 | $remember_me = isset($params['remember_me']) && ($params['remember_me']); |
Line 102... | Line 106... | ||
102 | OIDplus::logger()->log("V2:[WARN]A", "Failed login to admin account"); |
106 | OIDplus::logger()->log("V2:[WARN]A", "Failed login to admin account"); |
103 | } |
107 | } |
104 | throw new OIDplusException(_L('Wrong password')); |
108 | throw new OIDplusException(_L('Wrong password')); |
105 | } |
109 | } |
106 | } |
110 | } |
- | 111 | ||
- | 112 | /** |
|
- | 113 | * @param array $params |
|
- | 114 | * @return array |
|
- | 115 | * @throws OIDplusException |
|
- | 116 | */ |
|
107 | else if ($actionID == 'admin_logout') { |
117 | private function action_AdminLogout(array $params): array { |
108 | OIDplus::authUtils()->adminLogoutEx(); |
118 | OIDplus::authUtils()->adminLogoutEx(); |
109 | 119 | ||
110 | return array("status" => 0); |
120 | return array("status" => 0); |
111 | } |
121 | } |
- | 122 | ||
- | 123 | /** |
|
- | 124 | * @param string $actionID |
|
- | 125 | * @param array $params |
|
- | 126 | * @return array |
|
- | 127 | * @throws OIDplusException |
|
- | 128 | */ |
|
- | 129 | public function action(string $actionID, array $params): array { |
|
- | 130 | if ($actionID == 'ra_login') { |
|
- | 131 | return $this->action_RaLogin($params); |
|
- | 132 | } else if ($actionID == 'ra_logout') { |
|
- | 133 | return $this->action_RaLogout($params); |
|
- | 134 | } else if ($actionID == 'admin_login') { |
|
- | 135 | return $this->action_AdminLogin($params); |
|
- | 136 | } else if ($actionID == 'admin_logout') { |
|
- | 137 | return $this->action_AdminLogout($params); |
|
112 | else { |
138 | } else { |
113 | return parent::action($actionID, $params); |
139 | return parent::action($actionID, $params); |
114 | } |
140 | } |
115 | } |
141 | } |
116 | 142 | ||
117 | /** |
143 | /** |