I've used the maker bundle to create a standard login form. When the user has successfully logged in it calls function onAuthenticationSuccess to redirect to the new page.
public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
return new RedirectResponse($this->urlGenerator->generate('app_homepage'));
}
However, I would like to redirect to different pages depending on what role the user has. I would like to do something like:
if ($this->security->isGranted('ROLE_STANDARD_USER')) {
return new RedirectResponse($this->urlGenerator->generate('app_homepage'));
}
if ($this->security->isGranted('ROLE_SYS_ADMIN')) {
return new RedirectResponse($this->urlGenerator->generate('app_ADMINpage'));
}
But the error I'm getting is Undefined property: App\Security\LoginFormAuthenticator::$security
Many thanks in advance for the help.