XAV.EXE
XAV.EXE

Reputation: 109

Django: User only access to certain subdomain

I got subdomains setup via django-subdomains and the django sites framework but I got problem and that is that I don't know how I can link Users to have access to only a certain subdomain. For example user1 from company1 only has acces to company1.arandomdomain.com

Upvotes: 2

Views: 478

Answers (1)

XAV.EXE
XAV.EXE

Reputation: 109

Found the answer here How to get unique users across multiple Django sites powered by the "sites" framework?

In short you have to write your own authentication backend to check for they condition you need to check. See docs here https://docs.djangoproject.com/en/1.7/topics/auth/customizing/#writing-an-authentication-backend

In my case I had to check first if the user is an admin so he/she can go and otherwise I had to check the userprofile which is linked a site and match that to the current site.

Upvotes: 1

Related Questions