|
|
@@ -2,6 +2,9 @@ |
|
|
|
|
|
|
|
namespace Lc\SovBundle\Authenticator; |
|
|
|
|
|
|
|
use Lc\SovBundle\Builder\User\UserBuilder; |
|
|
|
use Lc\SovBundle\Container\User\UserContainer; |
|
|
|
use Lc\SovBundle\Model\User\UserInterface; |
|
|
|
use Lc\SovBundle\Repository\User\UserStore; |
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
|
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
|
@@ -28,17 +31,19 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator |
|
|
|
|
|
|
|
protected UrlGeneratorInterface $urlGenerator; |
|
|
|
protected UserStore $userStore; |
|
|
|
protected UserBuilder $userBuilder; |
|
|
|
protected FormFactoryInterface $formFactory; |
|
|
|
protected ParameterBagInterface $parameterBag; |
|
|
|
|
|
|
|
public function __construct( |
|
|
|
UrlGeneratorInterface $urlGenerator, |
|
|
|
UserStore $userStore, |
|
|
|
UserContainer $userContainer, |
|
|
|
FormFactoryInterface $formFactory, |
|
|
|
ParameterBagInterface $parameterBag |
|
|
|
) { |
|
|
|
$this->urlGenerator = $urlGenerator; |
|
|
|
$this->userStore = $userStore; |
|
|
|
$this->userStore = $userContainer->getStore(); |
|
|
|
$this->userBuilder = $userContainer->getBuilder(); |
|
|
|
$this->formFactory = $formFactory; |
|
|
|
$this->parameterBag = $parameterBag; |
|
|
|
} |
|
|
@@ -50,6 +55,7 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator |
|
|
|
|
|
|
|
public function authenticate(Request $request): PassportInterface |
|
|
|
{ |
|
|
|
|
|
|
|
$email = trim($request->request->get('email')); |
|
|
|
$password = $request->request->get('password'); |
|
|
|
$csrfToken = $request->request->get('_csrf_token'); |
|
|
@@ -71,17 +77,21 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator |
|
|
|
TokenInterface $token, |
|
|
|
string $providerKey |
|
|
|
): RedirectResponse { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$routeName = 'home'; |
|
|
|
$email = $request->request->get('email'); |
|
|
|
$email = trim($request->request->get('email')); |
|
|
|
$loginRedirection = $this->parameterBag->get('lc_sov.login_redirection'); |
|
|
|
$useReferer = $loginRedirection['redirect_referer']; |
|
|
|
$rolesRedirection = $loginRedirection['roles_redirection']; |
|
|
|
|
|
|
|
|
|
|
|
$user = $this->userStore->getOneByEmail($email); |
|
|
|
|
|
|
|
if (isset($useReferer) && $useReferer == true) { |
|
|
|
$url = $request->request->get('_target_path'); |
|
|
|
} else { |
|
|
|
$user = $this->userStore->getOneByEmail($email); |
|
|
|
|
|
|
|
if (!empty($user)) { |
|
|
|
$roles = $user->getRoles(); |
|
|
|
|
|
|
@@ -92,6 +102,7 @@ class LoginFormAuthenticator extends AbstractLoginFormAuthenticator |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$this->userBuilder->setLastLogin($user); |
|
|
|
|
|
|
|
if (isset($url) && !empty($url)) { |
|
|
|
return new RedirectResponse($url); |