Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview website as user / user-role of choice (masquerade-as function) #122

Open
nwaelkens opened this issue Aug 14, 2017 · 6 comments
Open

Comments

@nwaelkens
Copy link

Q A
Bug? no
New Feature? yes

Actual Behavior

The admin can preview pages meant for registered users only, but misses the member-elements on that page (logged-in bar with menu, reaction-form, etc). This is quite confusing.

The preview in the backend partly ignores if you are logged in as a user or not.

  1. It ignores my Accesscontrol rules defined in the websites' security.yml (that's good I guess).
  2. In my twig-template I'm using {% if app.user %} to show/hide a member menu and/or other items for logged in users only. {% if app.user %} resolves always to false. That's unwanted behaviour and creates pages for the content-editor which do not exist.

Expected Behavior / Solution

The feature I'm proposing is a masquerade-as-user option within the preview. See my screenshots.
I suggest:

  • if a website has 1-10 users, show them in the dropdown list box (see second screenshot)
  • if a website has more users, use a text input field with auto-complete. Under the textfield there can be space for the 5 'used' users.

Just a suggestion off course. This would be a great tool to preview the website, specially in combination with SuluCommunityBundle.
Drupal has a module 'Masquerade' which does this. https://www.drupal.org/project/masquerade

My screenshots:
screen shot 2017-08-14 at 10 24 50

screen shot 2017-08-14 at 10 25 09

@alexander-schranz
Copy link
Member

Think this is not easy to be implemented and maybe its part of the sulu community bundle /cc @wachterjohannes what you think?

@nwaelkens in the controller you know if you are in the preview: https://github.com/sulu/sulu/blob/develop/src/Sulu/Bundle/WebsiteBundle/Controller/DefaultController.php#L32 so you could set it to the view:

    public function indexAction(StructureInterface $structure, $preview = false, $partial = false)
    {
        $response = $this->renderStructure(
            $structure,
            [
                 'preview' => $preview,
            ],
            $preview,
            $partial
        );
        return $response;
    }

So you can check with {% if preview %} maybe this helps you.

@nwaelkens
Copy link
Author

@alexander-schranz: That's for the moment indeed a solution for me, tnx!

@wachterjohannes
Copy link
Member

I don't know how we should handle that in the admin. maybe we could do it in community-bundle but also there we don't know what changes when the user is logged in. the only way would be to fake the user - but this will be quite hard to achieve.

@alexander-schranz
Copy link
Member

@wachterjohannes as we have an own kernel for Preview there could be an PreviewUserProvider this need only return a Symfony UserInterface for the roles. But don't know how much work is to add a roles dropdown in a third party bundle. And how to add a parameter which role is selected. But for me its definitly part of the community bundle.

@wachterjohannes
Copy link
Member

tbh for the current UI this is nearly impossible to extend by a third party bundle. this should be part of 2.0 refactoring.

@danrot
Copy link

danrot commented Nov 27, 2019

@alexander-schranz I also see that as a part of the CommunityBundle, therfore going to transfer the issue.

@danrot danrot transferred this issue from sulu/sulu Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants