<?php
namespace LoyxxSW6ConversionCheckout\Storefront\Controller;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLoginRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractLogoutRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractResetPasswordRoute;
use Shopware\Core\Checkout\Customer\SalesChannel\AbstractSendPasswordRecoveryMailRoute;
use Shopware\Core\Framework\Routing\Annotation\Since;
use Shopware\Core\System\SalesChannel\Context\SalesChannelContextServiceInterface;
use Shopware\Storefront\Checkout\Cart\SalesChannel\StorefrontCartFacade;
use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Framework\Routing\Annotation\NoStore;
use Shopware\Storefront\Page\Account\Login\AccountLoginPageLoader;
use Shopware\Storefront\Page\Account\RecoverPassword\AccountRecoverPasswordPageLoader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route(defaults={"_routeScope"={"storefront"}})
*/
class AuthController extends \Shopware\Storefront\Controller\AuthController
{
private AccountLoginPageLoader $loginPageLoader;
private AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute;
private AbstractResetPasswordRoute $resetPasswordRoute;
private AbstractLoginRoute $loginRoute;
private AbstractLogoutRoute $logoutRoute;
private StorefrontCartFacade $cartFacade;
private SystemConfigService $systemConfig;
private AccountRecoverPasswordPageLoader $recoverPasswordPageLoader;
private SalesChannelContextServiceInterface $salesChannelContextService;
public function __construct(
AccountLoginPageLoader $loginPageLoader,
AbstractSendPasswordRecoveryMailRoute $sendPasswordRecoveryMailRoute,
AbstractResetPasswordRoute $resetPasswordRoute,
AbstractLoginRoute $loginRoute,
AbstractLogoutRoute $logoutRoute,
StorefrontCartFacade $cartFacade,
AccountRecoverPasswordPageLoader $recoverPasswordPageLoader,
SalesChannelContextServiceInterface $salesChannelContextService
)
{
parent::__construct(
$loginPageLoader,
$sendPasswordRecoveryMailRoute,
$resetPasswordRoute,
$loginRoute,
$logoutRoute,
$cartFacade,
$recoverPasswordPageLoader,
$salesChannelContextService
);
$this->loginPageLoader = $loginPageLoader;
$this->sendPasswordRecoveryMailRoute = $sendPasswordRecoveryMailRoute;
$this->resetPasswordRoute = $resetPasswordRoute;
$this->loginRoute = $loginRoute;
$this->logoutRoute = $logoutRoute;
$this->cartFacade = $cartFacade;
$this->recoverPasswordPageLoader = $recoverPasswordPageLoader;
$this->salesChannelContextService = $salesChannelContextService;
}
/**
* @Since("6.0.0.0")
* @Route("/account/login", name="frontend.account.login.page", methods={"GET"})
* @NoStore
*/
public function loginPage(Request $request, RequestDataBag $data, SalesChannelContext $context): Response
{
/** @var string $redirect */
$redirect = $request->get('redirectTo', 'frontend.account.home.page');
$customer = $context->getCustomer();
if ($customer !== null && $customer->getGuest() === false) {
$request->request->set('redirectTo', $redirect);
return $this->createActionResponse($request);
}
$page = $this->loginPageLoader->load($request, $context);
$view = '@Storefront/storefront/page/account/register/index.html.twig';
if ($request->get('persistCheckoutWindow', false)) {
$view = '@Storefront/storefront/page/checkout/address/index.html.twig';
}
return $this->renderStorefront($view, [
'redirectTo' => $redirect,
'redirectParameters' => $request->get('redirectParameters', json_encode([])),
'page' => $page,
'loginError' => (bool)$request->get('loginError'),
'errorSnippet' => $request->get('errorSnippet'),
'data' => $data,
]);
}
}