sulu / sulu-standard

This repository is not longer the recommended way to start a sulu project. Use:
https://github.com/sulu/skeleton
MIT License
614 stars 106 forks source link

Conflict between user's locale et portal's locale #482

Closed mbarbey closed 9 years ago

mbarbey commented 9 years ago

Hello,

I had some problems with the snippet part of the admin with an error saying I am not authorized to access this section. After digging a little, I found that the url was : admin/#snippet/snippets/en. BUT, the website is only in french, so there is no english content. And if I replace the "en" with "fr", everything work fine.

After some research and test, I found that the "en" come from the locale used to display the admin (by default : "en" or "de").

How to reproduce

  1. Create a portal with a language which is not available as admin language too
  2. Navigate to snippets
  3. Get an error
  4. Change the locale in the url
  5. Everything work fine

Logs [2015-08-03 17:44:02] request.INFO: Matched route "get_snippets" (parameters: "_controller": "sulu_snippet.controller.snippet:getSnippetsAction", "_format": "json", "_route": "get_snippets") [] [] [2015-08-03 17:44:02] security.DEBUG: Read SecurityContext from the session [] [] [2015-08-03 17:44:02] security.DEBUG: Reloading user from user provider. [] [] [2015-08-03 17:44:02] security.DEBUG: Username "admin" was reloaded from user provider. [] [] [2015-08-03 17:44:02] security.DEBUG: Access is denied (and user is neither anonymous, nor remember-me) by "C:\wamp\www\SUA0000\vendor\sulu\sulu\src\Sulu\Component\Security\Authorization\AbstractSecurityChecker.php" at line 41 [] [] [2015-08-03 17:44:02] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: "Permission "view" in localization "en" for object with id "" and of type "" not granted" at C:\wamp\www\SUA0000\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ExceptionListener.php line 117 {"exception":"[object](Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException%28code: 0%29: Permission "view" in localization "en" for object with id "" and of type "" not granted at C:\wamp\www\SUA0000\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ExceptionListener.php:117, Symfony\Component\Security\Core\Exception\AccessDeniedException%28code: 403%29: Permission "view" in localization "en" for object with id "" and of type "" not granted at C:\wamp\www\SUA0000\vendor\sulu\sulu\src\Sulu\Component\Security\Authorization\AbstractSecurityChecker.php:41)"} [] [2015-08-03 17:44:02] security.DEBUG: Write SecurityContext in the session [] []

It seem that the error occur on the "Excerpt & Categories" tab of the page edition too. Logs [2015-08-03 17:44:56] request.INFO: Matched route "get_categories" (parameters: "_controller": "Sulu\Bundle\CategoryBundle\Controller\CategoryController::cgetAction", "_format": "json", "_route": "get_categories") [] [] [2015-08-03 17:44:57] security.DEBUG: Read SecurityContext from the session [] [] [2015-08-03 17:44:57] security.DEBUG: Reloading user from user provider. [] [] [2015-08-03 17:44:57] security.DEBUG: Username "admin" was reloaded from user provider. [] [] [2015-08-03 17:44:57] security.DEBUG: Access is denied (and user is neither anonymous, nor remember-me) by "C:\wamp\www\SUA0000\vendor\sulu\sulu\src\Sulu\Component\Security\Authorization\AbstractSecurityChecker.php" at line 41 [] [] [2015-08-03 17:44:57] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: "Permission "view" in localization "en" for object with id "" and of type "" not granted" at C:\wamp\www\SUA0000\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ExceptionListener.php line 117 {"exception":"[object](Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException%28code: 0%29: Permission "view" in localization "en" for object with id "" and of type "" not granted at C:\wamp\www\SUA0000\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\ExceptionListener.php:117, Symfony\Component\Security\Core\Exception\AccessDeniedException%28code: 403%29: Permission "view" in localization "en" for object with id "" and of type "" not granted at C:\wamp\www\SUA0000\vendor\sulu\sulu\src\Sulu\Component\Security\Authorization\AbstractSecurityChecker.php:41)"} [] [2015-08-03 17:44:57] security.DEBUG: Write SecurityContext in the session [] []

wachterjohannes commented 9 years ago

thanks for reporting and such a detailed description! we will take a look a this (:

alexander-schranz commented 9 years ago

I have a similiar issue. I have a webspace which only have EN. My backoffice user was created as DE. After I changed my password I was not able to access any part of the bundles, because on the user save the permissons was saved with only EN (DE is missing in the dropdown). The permission dropdown should contain all backoffice and webspace localizations.

alexander-schranz commented 9 years ago

As a quickfix I did add the missing language in se_user_roles table this will work aslong as the contact permissions are not change in the backoffice.

danrot commented 9 years ago

I fixed the issue with the snippets (you immediately get to the right language afterwards), but I can't reproduce your second issue... Can you provide more information about it?

mbarbey commented 9 years ago

Well, maybe it's fixed with your changes.

The problem was that you can create a page (in FR), but when you open the tab "Excerpt & Categories", there was a loading where the categories should be, and after few seconds, there was the same error message, saying that I don't have enough permissions, and the categories were never displayed. And in the log, there was what I posted in my previous message, saying that I was searching some categories with the language EN (instead of FR), and then returning an error.

But if you don't have this problem, maybe it's fixed.

danrot commented 9 years ago

Ok, then I will close this issue, and you can reopen it, in case you will still encounter this issue. The strange thing is that I also wasn't able to reproduce it before...