mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
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:
parent
be417ef236
commit
4d4147b228
6 changed files with 76 additions and 9 deletions
|
@ -8,6 +8,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
|
||||
use Wallabag\CoreBundle\Entity\Config;
|
||||
use Wallabag\CoreBundle\Entity\TaggingRule;
|
||||
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
|
||||
|
@ -341,11 +342,13 @@ class ConfigController extends Controller
|
|||
*/
|
||||
public function setLocaleAction(Request $request, $language = null)
|
||||
{
|
||||
if (null !== $language) {
|
||||
$this->get('session')->set('_locale', $language);
|
||||
$errors = $this->get('validator')->validate($language, (new LocaleConstraint()));
|
||||
|
||||
if (0 === \count($errors)) {
|
||||
$request->getSession()->set('_locale', $language);
|
||||
}
|
||||
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
return $this->redirect($request->headers->get('referer', $this->generateUrl('homepage')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue