julianwachholz / django-guest-user

A Django app that allows visitors to interact with your site as a guest user without requiring registration.
https://django-guest-user.readthedocs.io/
MIT License
74 stars 10 forks source link

Using django-guest-user on the home page #12

Open rcavezza opened 8 months ago

rcavezza commented 8 months ago

I'm using django-guest-user on my home page to allow visitors to get some use out of the website before forcing them to register as users. The problem is (and I can't figure a way around it yet) is dealing with user Login after a user visits the homepage. Since I only @allow_guest_user on the homepage, I assumed that if you clicked to login, it would stop the guest user experience, but I'm assuming that isn't exactly how it works.

Are there any tricks or workarounds to allowing logins for someone considered a "guest user" who is actually another user logged out who is visiting the site?

Thanks again for the package - this is solving a huge use case for me!

julianwachholz commented 7 months ago

Hey @rcavezza, thank you for the kind words and bringing up this discussion.

Logging in to an existing account while already authenticated as a guest user should work as expected. The only requirement for this to work is that your login page doesn't redirect already-authenticated users elsewhere. With django-allauth for example, this requires the setting ACCOUNT_AUTHENTICATED_LOGIN_REDIRECTS = False.

However, this means if an existing user interacts with your sites and notices too late that they're not logged in to their real account, they could face loss of data. A sort of user merging needs to happen in this case, which unfortunately can't happen automatically at this time. There has been a previous discussion about this over a decade ago (by yours truly!). Does it sound similar to the problem you're facing?