Thursday, March 3, 2011

logging in a user to more than one site

Hi,

i have a problem with logging in a user to more than one site.
SIte A and B are on the same subdomain.

When a user visits site B, he is redirected to site A.
Site A shows a login screen, checks the credentials with LDAP.
After a succesful login, the user is redirected back to site B.

However, when I then visit site A, the user is logged out (Anonymous)
The userdatabase is in the database of site A and site B gets the info
by using multiple databases and thus getting the info from site A.

As for some more detailed info, site B has a login view.
From there, I redirect to site A with a return param specified as GET parameter to
this same login view.
When i get there, i receive the user id, and get the user like this (in the backend to authenticate)

user = User.objects.using('central_users').get(pk=key)

where 'central_users' is specified in settings.py:

'central_users': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'site A',
'USER': 'xxx',
'PASSWORD': 'xxx',
'HOST': 'localhost',
'PORT': '',
}

This finally works but as i said, I then run into problems on site A, the user is logged out.
The user is first logged in, in site A when i check the credentials.

Would this have anything to do with the fact that the user gets logged out later?

Trying to log in a user to more than 1 site is more frustrating than i thought :)

Regards,
Benedict

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment