forked from wallabag/wallabag
Ensure language is valid
- Do not override locale if user has choosen a locale from the login screen. - Add some tests about locale url
This commit is contained in:
@ -6,8 +6,10 @@ use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
|
||||
|
||||
/**
|
||||
* Stores the locale of the user in the session after the
|
||||
* login. This can be used by the LocaleListener afterwards.
|
||||
* Stores the locale of the user in the session after the login.
|
||||
* If no locale are defined (if user doesn't change it from the login screen), override it with the user's config one.
|
||||
*
|
||||
* This can be used by the LocaleListener afterwards.
|
||||
*
|
||||
* @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html
|
||||
*/
|
||||
@ -30,7 +32,7 @@ class UserLocaleListener
|
||||
{
|
||||
$user = $event->getAuthenticationToken()->getUser();
|
||||
|
||||
if (null !== $user->getConfig()->getLanguage()) {
|
||||
if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) {
|
||||
$this->session->set('_locale', $user->getConfig()->getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user