Support Forums

How to gate all content in website to Netlify Identity member?

@hrishikesh removed; as you can see it no longer reloads the page; but the same problem still occurs if you reload manually.

If a user is authenticated then the gated content should be shown regardless of how the page is reloaded.

That’s true. It should and it does work as you could see in my test. Which is why I’m trying to debug this and that would need me to be remove everything and put it back one-by-one to see what causes the problem.

If you can instead share your code directly, I can do all the tests myself and revert with the final answer. I could manually scrape all your pages and download them, but it could be easier if you could share it yourself.

I have sent you a link to a ZIP file in a DM.

The strange thing is you can’t even cache bust on reload by introducing a query param (i.e. ?t=234234).

Thanks for sharing. I’ll check it and let you know.

Hi @kruncher,

So, I’ve tested some stuff, but before I draw any conclusions, let me know if you notice the same behaviour.

Now my setup is almost same as yours. So, when I sign up as a new user (the new user won’t have any role), I face the redirect loop. However, if I sign out, assign the new user the role member and login, it works fine.

Can you please try to see if you get the same results with this repo: GitHub - Hrishikesh-K/identity2? You could manually deploy it as a different website.

@hrishikesh I have switched to the _redirects file that you are using. The role is (and always was) on the account before attempting to login; and Netlify is still serving the login page even after gated content should be permitted. I am experiencing the same issue with your repository as well.

Hi @kruncher ,

I’m sorry, I just can’t reproduce this. After setting the role, the website works absolutely fine. I’ve deployed that repo from above here: https://kind-darwin-f9963c.netlify.app/.

If you sign up as a new user (you can use a random email address, autoconfirm is enabled), you can see it going in a redirect loop like you mention. But if you login as:

Email: test@test.com
Password: test

(this user has the role set), the website works as expected. Note, homepage shows 404 as there’s no index.html.

@hrishikesh the test users on our site have the correct role and, as you have seen, do not show the gated content immediately upon signing in even with the same _redirects file as from your repository. It’s a very empty project.

If I go to /en/test/ and login it doesn’t show the gated content at /en/test/ it continues to show the login page. If I navigate to /en/ it does show gated content immediately. /en/test/ continues to show the login page for quite some time despite the user being logged in and having the correct role.

@hrishikesh if I login to /test/ and then refresh it still shows the login page for a while… but if I navigate to /test (removing the trailing slash) after having logged into /test/ the gated content shows immediately. The same is true if I login to /test and then navigate to /test/ (it works on /test/ after logging in on /test). There is definitely an issue here.

I tried as you suggested:

…but I really can’t reproduce it.

I’m not denying that the problem might exist, it might, and if it does I’d like to see it so that the developer team can possibly fix it. But, nothing I do seems to reproduce this.

1 Like

@hrishikesh Here is a behind-the-scenes of how it isn’t working for me: Screen Recording 2021-07-23 at 12.07.53.mov - Google Drive