mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Fix leak of private information when updating users
This commit is contained in:
parent
c6aeeeb3c1
commit
0536b208e1
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Api\Serializer\CurrentUserSerializer;
|
||||
use Flarum\Api\Serializer\UserSerializer;
|
||||
use Flarum\Core\Command\EditUser;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
|
@ -22,7 +24,7 @@ class UpdateUserController extends AbstractResourceController
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $serializer = 'Flarum\Api\Serializer\CurrentUserSerializer';
|
||||
public $serializer = UserSerializer::class;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -51,6 +53,10 @@ class UpdateUserController extends AbstractResourceController
|
|||
$actor = $request->getAttribute('actor');
|
||||
$data = array_get($request->getParsedBody(), 'data', []);
|
||||
|
||||
if ($actor->id == $id) {
|
||||
$this->serializer = CurrentUserSerializer::class;
|
||||
}
|
||||
|
||||
// Require the user's current password if they are attempting to change
|
||||
// their own email address.
|
||||
if (isset($data['attributes']['email']) && $actor->id == $id) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user