| @@ 283-290 (lines=8) @@ | ||
| 280 | // reset usermapper and copy in valid data |
|
| 281 | $mapper->load(['uuid = ?', $data['uuid']]); |
|
| 282 | $mapper->copyfrom($data); |
|
| 283 | if ($mapper->save()) { |
|
| 284 | $this->notify(_('The config data was updated!'), 'success'); |
|
| 285 | } else { |
|
| 286 | $this->notify(_('Unable to update config data!'), 'error'); |
|
| 287 | $f3->set('form', $f3->get('REQUEST')); |
|
| 288 | echo \View::instance()->render($view); |
|
| 289 | return; |
|
| 290 | } |
|
| 291 | ||
| 292 | $f3->reroute('@admin_config_search' . '?search=' . $mapper->uuid); |
|
| 293 | } |
|
| @@ 400-407 (lines=8) @@ | ||
| 397 | // reset usermapper and copy in valid data |
|
| 398 | $mapper->load(['uuid = ?', $mapper->uuid]); |
|
| 399 | $mapper->copyfrom($data); |
|
| 400 | if ($mapper->save()) { |
|
| 401 | $this->notify(_('The config data was updated!'), 'success'); |
|
| 402 | } else { |
|
| 403 | $this->notify(_('Unable to update config data!'), 'error'); |
|
| 404 | $f3->set('form', $f3->get('REQUEST')); |
|
| 405 | echo \View::instance()->render($view); |
|
| 406 | return; |
|
| 407 | } |
|
| 408 | ||
| 409 | $f3->reroute('@admin_config_edit' . '?uuid=' . $mapper->uuid); |
|
| 410 | } |
|
| @@ 315-322 (lines=8) @@ | ||
| 312 | // reset usermapper and copy in valid data |
|
| 313 | $mapper->load(['uuid = ?', $data['uuid']]); |
|
| 314 | $mapper->copyfrom($data); |
|
| 315 | if ($mapper->save()) { |
|
| 316 | $this->notify(_('The page data was updated!'), 'success'); |
|
| 317 | } else { |
|
| 318 | $this->notify(_('Unable to update page data!'), 'error'); |
|
| 319 | $f3->set('form', $f3->get('REQUEST')); |
|
| 320 | echo \View::instance()->render($view); |
|
| 321 | return; |
|
| 322 | } |
|
| 323 | ||
| 324 | $f3->reroute('@admin_pages_search' . '?search=' . $mapper->uuid); |
|
| 325 | } |
|
| @@ 424-431 (lines=8) @@ | ||
| 421 | // reset usermapper and copy in valid data |
|
| 422 | $mapper->load(['uuid = ?', $mapper->uuid]); |
|
| 423 | $mapper->copyfrom($data); |
|
| 424 | if ($mapper->save()) { |
|
| 425 | $this->notify(_('The page data was updated!'), 'success'); |
|
| 426 | } else { |
|
| 427 | $this->notify(_('Unable to update page data!'), 'error'); |
|
| 428 | $f3->set('form', $data); |
|
| 429 | echo \View::instance()->render($view); |
|
| 430 | return; |
|
| 431 | } |
|
| 432 | ||
| 433 | $f3->reroute('@admin_pages_search' . '?search=' . $mapper->uuid); |
|
| 434 | } |
|
| @@ 213-220 (lines=8) @@ | ||
| 210 | // reset usermapper and copy in valid data |
|
| 211 | $mapper->load(['uuid = ?', $data['uuid']]); |
|
| 212 | $mapper->copyfrom($data); |
|
| 213 | if ($mapper->save()) { |
|
| 214 | $this->notify(_('The report data was updated!'), 'success'); |
|
| 215 | } else { |
|
| 216 | $this->notify(_('Unable to update report data!'), 'error'); |
|
| 217 | $f3->set('form', $f3->get('REQUEST')); |
|
| 218 | echo \View::instance()->render($view); |
|
| 219 | return; |
|
| 220 | } |
|
| 221 | ||
| 222 | $f3->reroute('@admin_reports_search' . '?search=' . $mapper->uuid); |
|
| 223 | } |
|
| @@ 348-355 (lines=8) @@ | ||
| 345 | // reset usermapper and copy in valid data |
|
| 346 | $mapper->load(['uuid = ?', $mapper->uuid]); |
|
| 347 | $mapper->copyfrom($data); |
|
| 348 | if ($mapper->save()) { |
|
| 349 | $this->notify(_('The report data was updated!'), 'success'); |
|
| 350 | } else { |
|
| 351 | $this->notify(_('Unable to update report data!'), 'error'); |
|
| 352 | $f3->set('form', $f3->get('REQUEST')); |
|
| 353 | echo \View::instance()->render($view); |
|
| 354 | return; |
|
| 355 | } |
|
| 356 | ||
| 357 | $f3->reroute('@admin_reports_search' . '?search=' . $mapper->uuid); |
|
| 358 | } |
|
| @@ 137-142 (lines=6) @@ | ||
| 134 | $usersModel = Models\Users::instance(); |
|
| 135 | $uuid = $f3->get('REQUEST.uuid'); |
|
| 136 | $usersMapper = $usersModel->getUserByUUID($uuid); |
|
| 137 | if (null == $usersMapper->id) { |
|
| 138 | $this->notify(_('The account no longer exists!'), 'error'); |
|
| 139 | $f3->set('form', $f3->get('REQUEST')); |
|
| 140 | echo \View::instance()->render('user/account.phtml'); |
|
| 141 | return; |
|
| 142 | } |
|
| 143 | $oldUserMapper = clone $usersMapper; |
|
| 144 | ||
| 145 | // only allow updating of these fields |
|
| @@ 224-229 (lines=6) @@ | ||
| 221 | } |
|
| 222 | ||
| 223 | // no change, do nothing |
|
| 224 | if ($usersMapper->cast() === $oldUserMapper->cast()) { |
|
| 225 | $this->notify(_('There was nothing to change!'), 'info'); |
|
| 226 | $f3->set('form', $f3->get('REQUEST')); |
|
| 227 | echo \View::instance()->render($view); |
|
| 228 | return; |
|
| 229 | } |
|
| 230 | ||
| 231 | // reset usermapper and copy in valid data |
|
| 232 | $usersMapper->load(['uuid = ?', $data['uuid']]); |
|
| @@ 234-241 (lines=8) @@ | ||
| 231 | // reset usermapper and copy in valid data |
|
| 232 | $usersMapper->load(['uuid = ?', $data['uuid']]); |
|
| 233 | $usersMapper->copyfrom($data); |
|
| 234 | if ($usersMapper->save()) { |
|
| 235 | $this->notify(_('The account was updated!'), 'success'); |
|
| 236 | } else { |
|
| 237 | $this->notify(_('Unable to update your account!'), 'error'); |
|
| 238 | $f3->set('form', $f3->get('REQUEST')); |
|
| 239 | echo \View::instance()->render($view); |
|
| 240 | return; |
|
| 241 | } |
|
| 242 | ||
| 243 | $f3->reroute('@admin_users_search' . '?search=' . $usersMapper->uuid); |
|
| 244 | } |
|
| @@ 273-280 (lines=8) @@ | ||
| 270 | // reset usermapper and copy in valid data |
|
| 271 | $mapper->load(['uuid = ?', $data['uuid']]); |
|
| 272 | $mapper->copyfrom($data); |
|
| 273 | if ($mapper->save()) { |
|
| 274 | $this->notify(_('The account data was updated!'), 'success'); |
|
| 275 | } else { |
|
| 276 | $this->notify(_('Unable to update account data!'), 'error'); |
|
| 277 | $f3->set('form', $f3->get('REQUEST')); |
|
| 278 | echo \View::instance()->render($view); |
|
| 279 | return; |
|
| 280 | } |
|
| 281 | ||
| 282 | $f3->reroute('@admin_usersdata_search' . '?search=' . $mapper->uuid); |
|
| 283 | } |
|
| @@ 409-416 (lines=8) @@ | ||
| 406 | // reset usermapper and copy in valid data |
|
| 407 | $mapper->load(['uuid = ?', $mapper->uuid]); |
|
| 408 | $mapper->copyfrom($data); |
|
| 409 | if ($mapper->save()) { |
|
| 410 | $this->notify(_('The account data was updated!'), 'success'); |
|
| 411 | } else { |
|
| 412 | $this->notify(_('Unable to update account data!'), 'error'); |
|
| 413 | $f3->set('form', $f3->get('REQUEST')); |
|
| 414 | echo \View::instance()->render($view); |
|
| 415 | return; |
|
| 416 | } |
|
| 417 | ||
| 418 | $f3->reroute('@admin_usersdata_edit' . '?uuid=' . $mapper->uuid); |
|
| 419 | } |
|
| @@ 177-182 (lines=6) @@ | ||
| 174 | } |
|
| 175 | ||
| 176 | // no valid scopes |
|
| 177 | if (empty($scopes)) { |
|
| 178 | $this->notify(_('No valid scope(s) specified'), 'error'); |
|
| 179 | $f3->set('form', $f3->get('REQUEST')); |
|
| 180 | echo \View::instance()->render($view); |
|
| 181 | return; |
|
| 182 | } |
|
| 183 | ||
| 184 | // verify client id is valid |
|
| 185 | $appsMapper->load(['client_id = ?', $request['client_id']]); |
|
| @@ 186-191 (lines=6) @@ | ||
| 183 | ||
| 184 | // verify client id is valid |
|
| 185 | $appsMapper->load(['client_id = ?', $request['client_id']]); |
|
| 186 | if (empty($appsMapper->client_id)) { |
|
| 187 | $this->notify(_('Unknown client id!'), 'error'); |
|
| 188 | $f3->set('form', $f3->get('REQUEST')); |
|
| 189 | echo \View::instance()->render($view); |
|
| 190 | return; |
|
| 191 | } |
|
| 192 | ||
| 193 | // verify client app status |
|
| 194 | if ('approved' !== $appsMapper->status) { |
|
| @@ 194-199 (lines=6) @@ | ||
| 191 | } |
|
| 192 | ||
| 193 | // verify client app status |
|
| 194 | if ('approved' !== $appsMapper->status) { |
|
| 195 | $this->notify(sprintf(_('Application status %s currently forbids access.'), $appsMapper->status), 'error'); |
|
| 196 | $f3->set('form', $f3->get('REQUEST')); |
|
| 197 | echo \View::instance()->render($view); |
|
| 198 | return; |
|
| 199 | } |
|
| 200 | ||
| 201 | if (empty($request['redirect_uri'])) { |
|
| 202 | $request['redirect_uri'] = $appsMapper->callback_uri; |
|
| @@ 161-166 (lines=6) @@ | ||
| 158 | ||
| 159 | // load in the forgot password reset code row |
|
| 160 | $usersDataMapper->load([$usersDataMapper->quotekey('value')." = ? AND ".$usersDataMapper->quotekey('key')." = 'forgot-password-code'", $f3->get('REQUEST.code')]); |
|
| 161 | if (null == $usersDataMapper->uuid) { |
|
| 162 | $this->notify(_('Unknown password reset code!'), 'error'); |
|
| 163 | $f3->set('form', $f3->get('REQUEST')); |
|
| 164 | echo \View::instance()->render($viewStep2); |
|
| 165 | return; |
|
| 166 | } |
|
| 167 | ||
| 168 | // check that the user exists for the reset code |
|
| 169 | $usersMapper->load(['uuid = ?', $usersDataMapper->users_uuid]); |
|
| @@ 170-175 (lines=6) @@ | ||
| 167 | ||
| 168 | // check that the user exists for the reset code |
|
| 169 | $usersMapper->load(['uuid = ?', $usersDataMapper->users_uuid]); |
|
| 170 | if (null == $usersDataMapper->uuid) { |
|
| 171 | $this->notify(_('Unknown user for reset code!'), 'error'); |
|
| 172 | $f3->set('form', $f3->get('REQUEST')); |
|
| 173 | echo \View::instance()->render($viewStep2); |
|
| 174 | return; |
|
| 175 | } |
|
| 176 | ||
| 177 | // valid data, show the reset password form |
|
| 178 | $this->notify(_("Password code is valid."), 'info'); |
|
| @@ 74-79 (lines=6) @@ | ||
| 71 | ||
| 72 | // find user by email address |
|
| 73 | $usersMapper = $usersModel->getUserByEmail($f3->get('REQUEST.email')); |
|
| 74 | if (null == $usersMapper->id) { |
|
| 75 | $this->notify(_('No user found with that email!'), 'error'); |
|
| 76 | $f3->set('form', $f3->get('REQUEST')); |
|
| 77 | echo \View::instance()->render($view); |
|
| 78 | return; |
|
| 79 | } |
|
| 80 | ||
| 81 | // check the password is set |
|
| 82 | $password = $f3->get('REQUEST.password'); |
|
| @@ 83-88 (lines=6) @@ | ||
| 80 | ||
| 81 | // check the password is set |
|
| 82 | $password = $f3->get('REQUEST.password'); |
|
| 83 | if (empty($password)) { |
|
| 84 | $this->notify(_('You must enter a password!'), 'warning'); |
|
| 85 | $f3->set('form', $f3->get('REQUEST')); |
|
| 86 | echo \View::instance()->render($view); |
|
| 87 | return; |
|
| 88 | } |
|
| 89 | ||
| 90 | // verify password |
|
| 91 | if (!Helpers\Str::passwordVerify($usersMapper->password, $password)) { |
|
| @@ 91-96 (lines=6) @@ | ||
| 88 | } |
|
| 89 | ||
| 90 | // verify password |
|
| 91 | if (!Helpers\Str::passwordVerify($usersMapper->password, $password)) { |
|
| 92 | $this->notify(_('Incorrect password!'), 'warning'); |
|
| 93 | $f3->set('form', $f3->get('REQUEST')); |
|
| 94 | echo \View::instance()->render($view); |
|
| 95 | return; |
|
| 96 | } |
|
| 97 | ||
| 98 | if (!$usersModel->login()) { |
|
| 99 | $this->notify(_('Unable to login!'), 'warning'); |
|
| @@ 151-156 (lines=6) @@ | ||
| 148 | // get current user details |
|
| 149 | $usersModel = Models\Users::instance(); |
|
| 150 | $usersMapper = $usersModel->getUserByUUID($f3->get('uuid')); |
|
| 151 | if (null == $usersMapper->id) { |
|
| 152 | $this->notify(_('Your account no longer exists!'), 'error'); |
|
| 153 | $f3->set('form', $f3->get('REQUEST')); |
|
| 154 | echo \View::instance()->render('user/account.phtml'); |
|
| 155 | return; |
|
| 156 | } |
|
| 157 | ||
| 158 | // check password is correct |
|
| 159 | $str = Helpers\Str::instance(); |
|
| @@ 246-251 (lines=6) @@ | ||
| 243 | } |
|
| 244 | ||
| 245 | // no change, do nothing |
|
| 246 | if (!$usersMapper->changed()) { |
|
| 247 | $this->notify(_('There was nothing to change!'), 'info'); |
|
| 248 | $f3->set('form', $f3->get('REQUEST')); |
|
| 249 | echo \View::instance()->render($view); |
|
| 250 | return; |
|
| 251 | } |
|
| 252 | ||
| 253 | // reset usermapper and copy in valid data |
|
| 254 | $usersMapper->load(['uuid = ?', $data['uuid']]); |
|
| @@ 256-263 (lines=8) @@ | ||
| 253 | // reset usermapper and copy in valid data |
|
| 254 | $usersMapper->load(['uuid = ?', $data['uuid']]); |
|
| 255 | $usersMapper->copyfrom($data); |
|
| 256 | if ($usersMapper->save()) { |
|
| 257 | $this->notify(_('Your account was updated!'), 'success'); |
|
| 258 | } else { |
|
| 259 | $this->notify(_('Unable to update your account!'), 'error'); |
|
| 260 | $f3->set('form', $f3->get('REQUEST')); |
|
| 261 | echo \View::instance()->render($view); |
|
| 262 | return; |
|
| 263 | } |
|
| 264 | ||
| 265 | // send verification email if email change - non-fatal |
|
| 266 | if ($usersMapper->changed()) { |
|
| @@ 324-329 (lines=6) @@ | ||
| 321 | $view = 'user/register.phtml'; |
|
| 322 | ||
| 323 | $email = $f3->get('REQUEST.email'); |
|
| 324 | if (empty($email)) { |
|
| 325 | $this->notify(_('You need to enter an email address!'), 'warning'); |
|
| 326 | $f3->set('form', $f3->get('REQUEST')); |
|
| 327 | echo \View::instance()->render($view); |
|
| 328 | return; |
|
| 329 | } |
|
| 330 | ||
| 331 | // find user by email address |
|
| 332 | $usersModel = Models\Users::instance(); |
|
| @@ 334-339 (lines=6) @@ | ||
| 331 | // find user by email address |
|
| 332 | $usersModel = Models\Users::instance(); |
|
| 333 | $usersMapper = $usersModel->getUserByEmail($email); |
|
| 334 | if (null !== $usersMapper->id) { |
|
| 335 | $this->notify(_('That user already exists!'), 'error'); |
|
| 336 | $f3->set('form', $f3->get('REQUEST')); |
|
| 337 | echo \View::instance()->render($view); |
|
| 338 | return; |
|
| 339 | } |
|
| 340 | ||
| 341 | // bad password |
|
| 342 | $password = $f3->get('REQUEST.password'); |
|
| @@ 377-382 (lines=6) @@ | ||
| 374 | return; |
|
| 375 | } |
|
| 376 | ||
| 377 | if (!$usersModel->register()) { |
|
| 378 | $this->notify(_('Registration failed!'), 'error'); |
|
| 379 | $f3->set('form', $f3->get('REQUEST')); |
|
| 380 | echo \View::instance()->render($view); |
|
| 381 | return; |
|
| 382 | } |
|
| 383 | $usersModel->login(); |
|
| 384 | $f3->set('SESSION.uuid', $usersMapper->uuid); |
|
| 385 | $f3->set('uuid', $usersMapper->uuid); |
|