stupidlysimple /
php
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * StupidlySimple - A PHP Framework For Lazy Developers. |
||
| 4 | * |
||
| 5 | * @author Fariz Luqman <[email protected]> |
||
| 6 | * @copyright 2017 Fariz Luqman |
||
| 7 | * @license MIT |
||
| 8 | * |
||
| 9 | * @link https://stupidlysimple.github.io/ |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Controller; |
||
| 13 | |||
| 14 | use Request; |
||
| 15 | use Response; |
||
| 16 | use Sentry; |
||
|
0 ignored issues
–
show
|
|||
| 17 | |||
| 18 | class User |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * User constructor. |
||
| 22 | */ |
||
| 23 | public function __construct() |
||
| 24 | { |
||
| 25 | // Always check whether the user is logged in or not to do the action |
||
| 26 | if (Sentry::check() !== true) { |
||
| 27 | Response::redirect('login'); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | public function editUser() |
||
| 32 | { |
||
| 33 | $id = Request::get('id'); |
||
| 34 | $first_name = Request::get('first_name'); |
||
| 35 | $last_name = Request::get('last_name'); |
||
| 36 | $password = Request::get('password'); |
||
| 37 | |||
| 38 | try { |
||
| 39 | if ($password == '') { |
||
| 40 | // change first_name and last_name |
||
| 41 | $user = \Model\User::find($id); |
||
|
0 ignored issues
–
show
|
|||
| 42 | $user->first_name = $first_name; |
||
| 43 | $user->last_name = $last_name; |
||
| 44 | $user->save(); |
||
| 45 | Response::redirect('admin?edit=success'); |
||
| 46 | } else { |
||
| 47 | // Find the user using the user id |
||
| 48 | $user = Sentry::findUserById($id); |
||
| 49 | |||
| 50 | // Get the password reset code |
||
| 51 | $resetCode = $user->getResetPasswordCode(); |
||
| 52 | |||
| 53 | // Check if the reset password code is valid |
||
| 54 | if ($user->checkResetPasswordCode($resetCode)) { |
||
| 55 | // Attempt to reset the user password |
||
| 56 | if ($user->attemptResetPassword($resetCode, $password)) { |
||
| 57 | // change first_name and last_name |
||
| 58 | $user = \Model\User::find($id); |
||
| 59 | $user->first_name = $first_name; |
||
| 60 | $user->last_name = $last_name; |
||
| 61 | $user->save(); |
||
| 62 | |||
| 63 | Response::redirect('admin?edit=success'); |
||
| 64 | } else { |
||
| 65 | // Password reset failed |
||
| 66 | echo 'Password reset failed'; |
||
| 67 | } |
||
| 68 | } else { |
||
| 69 | // The provided password reset code is Invalid |
||
| 70 | echo 'Invalid password reset code'; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } catch (\Exception $e) { |
||
| 74 | echo 'User was not found.'; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | public function deleteUser() |
||
| 79 | { |
||
| 80 | $id = Request::get('id'); |
||
| 81 | |||
| 82 | try { |
||
| 83 | $user = \Model\User::find($id); |
||
|
0 ignored issues
–
show
|
|||
| 84 | |||
| 85 | if ($user === null) { |
||
| 86 | Response::redirect('admin?delete=failed'); |
||
| 87 | } |
||
| 88 | |||
| 89 | $user->delete(); |
||
| 90 | } catch (\Exception $e) { |
||
| 91 | Response::redirect('admin?delete=failed'); |
||
| 92 | } |
||
| 93 | |||
| 94 | Response::redirect('admin?delete=success'); |
||
| 95 | } |
||
| 96 | } |
||
| 97 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths