44
55use Illuminate \Http \Request ;
66use Illuminate \Http \Response ;
7+ use Illuminate \Auth \AuthManager ;
8+ use Illuminate \Http \JsonResponse ;
79use Pterodactyl \Services \Users \UserUpdateService ;
810use Pterodactyl \Transformers \Api \Client \AccountTransformer ;
911use Pterodactyl \Http \Requests \Api \Client \Account \UpdateEmailRequest ;
@@ -16,16 +18,23 @@ class AccountController extends ClientApiController
1618 */
1719 private $ updateService ;
1820
21+ /**
22+ * @var \Illuminate\Auth\SessionGuard
23+ */
24+ private $ sessionGuard ;
25+
1926 /**
2027 * AccountController constructor.
2128 *
29+ * @param \Illuminate\Auth\AuthManager $sessionGuard
2230 * @param \Pterodactyl\Services\Users\UserUpdateService $updateService
2331 */
24- public function __construct (UserUpdateService $ updateService )
32+ public function __construct (AuthManager $ sessionGuard , UserUpdateService $ updateService )
2533 {
2634 parent ::__construct ();
2735
2836 $ this ->updateService = $ updateService ;
37+ $ this ->sessionGuard = $ sessionGuard ;
2938 }
3039
3140 /**
@@ -56,18 +65,21 @@ public function updateEmail(UpdateEmailRequest $request): Response
5665 }
5766
5867 /**
59- * Update the authenticated user's password.
68+ * Update the authenticated user's password. All existing sessions will be logged
69+ * out immediately.
6070 *
6171 * @param \Pterodactyl\Http\Requests\Api\Client\Account\UpdatePasswordRequest $request
62- * @return \Illuminate\Http\Response
72+ * @return \Illuminate\Http\JsonResponse
6373 *
6474 * @throws \Pterodactyl\Exceptions\Model\DataValidationException
6575 * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
6676 */
67- public function updatePassword (UpdatePasswordRequest $ request ): Response
77+ public function updatePassword (UpdatePasswordRequest $ request ): \ Illuminate \ Http \ JsonResponse
6878 {
6979 $ this ->updateService ->handle ($ request ->user (), $ request ->validated ());
7080
71- return response ('' , Response::HTTP_CREATED );
81+ $ this ->sessionGuard ->logoutOtherDevices ($ request ->input ('current_password ' ));
82+
83+ return JsonResponse::create ([], Response::HTTP_NO_CONTENT );
7284 }
7385}
0 commit comments