feat: move profile completeness check from login to booking flow entry
- Add profileComplete flag to User entity to avoid API calls - Set flag during login (BpnAuthenticator) and profile save - Check flag in IndexController when entering booking flow - Remove ProfileCompletionSubscriber (no longer needed) Users with incomplete profiles are only redirected when starting a new booking, not on every login. Eliminates extra API call by caching completeness status on the user entity.
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Booking\Create;
|
||||
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
use App\Controller\Account\PersonalDataController;
|
||||
use App\Entity\User;
|
||||
use App\Exception\HotelNotFoundException;
|
||||
use App\Exception\HotelNotInTravelException;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
@@ -42,17 +44,26 @@ class IndexController extends AbstractController
|
||||
*
|
||||
* Renders a loading page that triggers the actual initialization via HTMX.
|
||||
* This provides immediate visual feedback while BusProNet API calls are made.
|
||||
* Redirects to profile completion if logged-in user has incomplete profile data.
|
||||
*/
|
||||
#[Route(
|
||||
path: '/bookings/create',
|
||||
name: 'app_booking_create',
|
||||
)]
|
||||
public function index(#[MapQueryString] ?BookingQueryParams $params): Response
|
||||
public function index(Request $request, #[MapQueryString] ?BookingQueryParams $params): Response
|
||||
{
|
||||
if (null === $params) {
|
||||
throw $this->createNotFoundException('Invalid booking parameters provided');
|
||||
}
|
||||
|
||||
$user = $this->getUser();
|
||||
|
||||
if ($user instanceof User && false === $user->isProfileComplete()) {
|
||||
$request->getSession()->set(PersonalDataController::SESSION_REDIRECT_KEY, $request->getUri());
|
||||
|
||||
return $this->redirectToRoute('app_personal_data');
|
||||
}
|
||||
|
||||
return $this->render('booking/create/index.html.twig', [
|
||||
'params' => $params,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user