Fix changing a user password to not incorrectly handle logging out old sessions; closes #3531
This commit is contained in:
parent
25d9ba4779
commit
2b3303c46b
5 changed files with 32 additions and 28 deletions
|
@ -5,7 +5,6 @@ namespace Pterodactyl\Services\Users;
|
|||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Pterodactyl\Traits\Services\HasUserLevels;
|
||||
use Pterodactyl\Repositories\Eloquent\UserRepository;
|
||||
|
||||
class UserUpdateService
|
||||
{
|
||||
|
@ -16,29 +15,20 @@ class UserUpdateService
|
|||
*/
|
||||
private $hasher;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\UserRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* UpdateService constructor.
|
||||
*/
|
||||
public function __construct(Hasher $hasher, UserRepository $repository)
|
||||
public function __construct(Hasher $hasher)
|
||||
{
|
||||
$this->hasher = $hasher;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user model instance.
|
||||
* Update the user model instance and return the updated model.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function handle(User $user, array $data)
|
||||
public function handle(User $user, array $data): User
|
||||
{
|
||||
if (!empty(array_get($data, 'password'))) {
|
||||
$data['password'] = $this->hasher->make($data['password']);
|
||||
|
@ -46,9 +36,8 @@ class UserUpdateService
|
|||
unset($data['password']);
|
||||
}
|
||||
|
||||
/** @var \Pterodactyl\Models\User $response */
|
||||
$response = $this->repository->update($user->id, $data);
|
||||
$user->forceFill($data)->saveOrFail();
|
||||
|
||||
return $response;
|
||||
return $user->refresh();
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue