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

Have setting SPIRIT_AUTH_USER_MODEL (defaults to the AUTH_USER_MODEL) but can be overridden #319

Open
sureshvv opened this issue Aug 4, 2023 · 5 comments

Comments

@sureshvv
Copy link

sureshvv commented Aug 4, 2023

Don't want all users on my site to be spirit users

@nitely
Copy link
Owner

nitely commented Aug 4, 2023

I think there is no way to do that. If you share the DB between your site and Spirit, all users will be Spirit users. If you don't create a Spirit user profile, it won't matter, because the user is authenticated and assigned to request.user anyway. You would only get an error about the profile not existing for the user when visiting the Spirit user profile. on a second thought, if you point Spirit profile to some model other than the Django user model or a custom one defined as AUTH_USER_MODEL, Spirit won't work at all.

Not sure you can have two user models in Django.

@nitely
Copy link
Owner

nitely commented Aug 4, 2023

If you want to forbid some users from accessing the forum, you are better off creating a model with a OneToOneField to Django user model, and some is_forum_allowed field. Then use that field to check if the user can access the forum. The check can be done in a custom middleware similar to this one, but redirecting them to your site if they are not allowed.

@sureshvv
Copy link
Author

sureshvv commented Aug 4, 2023

I have done that. Only thing is still all the users show up in spirit:admin:users.

I was looking for a non-intrusive way of listing only the spirit users.

@nitely
Copy link
Owner

nitely commented Aug 4, 2023

ye, one way is monkey patching this view

@nitely
Copy link
Owner

nitely commented Aug 4, 2023

probably something like this in a custom app:

from spirit.user.admin import views
org_index = views._index
def new_index(request, queryset, template):
    return org_index(request, queryset.filter(custom_user__has_forum_access=True), template)
views._index = new_index

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

2 participants