Moved user retrieval to API
This commit is contained in:
parent
9e2e3ceb7f
commit
816859c3e3
2 changed files with 23 additions and 12 deletions
17
src/Api/Jobs/GetUserJob.php
Normal file
17
src/Api/Jobs/GetUserJob.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
class GetUserJob extends AbstractUserJob
|
||||
{
|
||||
public function execute()
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function requiresPrivilege()
|
||||
{
|
||||
return
|
||||
[
|
||||
Privilege::ViewUser,
|
||||
Access::getIdentity($this->user)
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue