diff --git a/src/Api/Jobs/GetUserJob.php b/src/Api/Jobs/GetUserJob.php new file mode 100644 index 00000000..71405ab9 --- /dev/null +++ b/src/Api/Jobs/GetUserJob.php @@ -0,0 +1,17 @@ +user; + } + + public function requiresPrivilege() + { + return + [ + Privilege::ViewUser, + Access::getIdentity($this->user) + ]; + } +} diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 0994017f..d8f02691 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -19,7 +19,12 @@ class UserController public function genericView($name, $tab = 'favs', $page = 1) { - $user = UserModel::findByNameOrEmail($name); + $user = Api::run( + new GetUserJob(), + [ + GetUserJob::USER_NAME => $name, + ]); + $flagged = in_array(TextHelper::reprUser($user), SessionHelper::get('flagged', [])); $context = getContext(); @@ -47,10 +52,6 @@ class UserController $context->transport->paginator = $ret; $context->transport->lastSearchQuery = $query; } - - Access::assert( - Privilege::ViewUser, - Access::getIdentity($user)); } public function settingsAction($name) @@ -59,9 +60,6 @@ class UserController $user = getContext()->transport->user; - Access::assert( - Privilege::ViewUser, - Access::getIdentity($user)); Access::assert( Privilege::ChangeUserSettings, Access::getIdentity($user)); @@ -91,10 +89,6 @@ class UserController $user = getContext()->transport->user; - Access::assert( - Privilege::ViewUser, - Access::getIdentity($user)); - $suppliedCurrentPassword = InputHelper::get('current-password'); $suppliedName = InputHelper::get('name'); $suppliedPassword1 = InputHelper::get('password1');