Re: custom User model and login()

2012-11-11 Thread Russell Keith-Magee
On Mon, Nov 12, 2012 at 2:08 AM, Anil Jangity  wrote:

> I am trying to build a User model with a dedicated LDAP backend. I have no
> SQL database.
>
> def login(request):
>...
>login(request, user)
>request.user.is_authenticated()   ---> return True
>return HttpResponseRedirect("/manage")
>
> def manage(request):
>print request.user.is_authenticated()--> returns False
>
> Shouldn't the manage() show the user being authenticated?
> What exactly happens when I do a login() call? Does it store some sessions
> somewhere? If so, what can I do in my custom User model to make it save
> this session?
>

Django logins are handled by a session, and sessions are saved by the
Session middleware when the response is passed back to the client. Django's
builtin login call returns a response that sets the new session for the
logged in user; however, you're throwing away that information and
returning your own response, so the session isn't being saved.

If you want to persist the session, you'll need to pull the relevant
session keys over from the response returned by the login call, and attach
them to the redirect response (or find some other sequence of events that
will let you get to the manage view).

Yours,
Russ Magee %-)

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



custom User model and login()

2012-11-11 Thread Anil Jangity
I am trying to build a User model with a dedicated LDAP backend. I have no SQL 
database.

def login(request):
   ...
   login(request, user)
   request.user.is_authenticated()   ---> return True
   return HttpResponseRedirect("/manage")

def manage(request):
   print request.user.is_authenticated()--> returns False

Shouldn't the manage() show the user being authenticated?
What exactly happens when I do a login() call? Does it store some sessions 
somewhere? If so, what can I do in my custom User model to make it save this 
session?

Thanks,
Anil



-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.