updateService = $updateService; $this->sessionGuard = $sessionGuard; } public function index(Request $request): array { return $this->fractal->item($request->user()) ->transformWith($this->getTransformer(AccountTransformer::class)) ->toArray(); } /** * Update the authenticated user's email address. * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function updateEmail(UpdateEmailRequest $request): JsonResponse { $this->updateService->handle($request->user(), $request->validated()); return new JsonResponse([], Response::HTTP_NO_CONTENT); } /** * Update the authenticated user's password. All existing sessions will be logged * out immediately. * * @throws \Throwable */ public function updatePassword(UpdatePasswordRequest $request): JsonResponse { $user = $this->updateService->handle($request->user(), $request->validated()); // If you do not update the user in the session you'll end up working with a // cached copy of the user that does not include the updated password. Do this // to correctly store the new user details in the guard and allow the logout // other devices functionality to work. $this->sessionGuard->setUser($user); $this->sessionGuard->logoutOtherDevices($request->input('password')); return new JsonResponse([], Response::HTTP_NO_CONTENT); } }