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

Admin-Views rendered as cache #15

Open
luke-nehemedia opened this issue Mar 2, 2019 · 3 comments
Open

Admin-Views rendered as cache #15

luke-nehemedia opened this issue Mar 2, 2019 · 3 comments

Comments

@luke-nehemedia
Copy link

For my client I provide "edit this entry"-links on the page if he is logged in. I also use a plugin called "admin bar" which displays a handy toolbar on top if the user is logged in.

Both of these get rendered in the cached file, espousing the admin's username and links to the CP-panel to the public. Access to the CP-area is still secured by password, of course, however, this is still far away from optimal.

Is there a way to modify the plugin that only the user's view is rendered, not the view of a logged in user?

@bragle
Copy link
Contributor

bragle commented Mar 2, 2019

I think the best approach would be to add an option in options panel that'll skip caching (and loading the cache) if an user is logged in.

Something like $skipCache = !Craft::$app->user->isGuest would probably do the trick. I can make a PR when I have time :)

@boldenamsterdam
Copy link
Owner

Hello,

Skipping cache for logged in users might not be the best approach. In that scenario it will also disable cache for the rest of the pages which defies the use of the plugin.

We are planning to release a version with whitelist of urls.
@luke-nehemedia would that solve your issue?

Till the new release you can use what @bragle suggested.

@luke-nehemedia
Copy link
Author

Whitelists will not solve the problem, although this feature would be great.

The problem is, that the page contains code that is rendered only if a user is logged in (for example "edit" links or the Admin-Bar-plugin). This markup should not be included in the cached versions, but only the Guest-view.

I am not sure how to implement the solution of @bragle, but it sounds promising. Cached versions of the site should only be created (and also loaded), if the user is not logged in.

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

3 participants