Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion custom User model and login()
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Russell Keith-Magee  
View profile  
 More options Nov 11 2012, 6:55 pm
From: Russell Keith-Magee <russ...@keith-magee.com>
Date: Mon, 12 Nov 2012 07:53:23 +0800
Local: Sun, Nov 11 2012 6:53 pm
Subject: Re: custom User model and login()

On Mon, Nov 12, 2012 at 2:08 AM, Anil Jangity <an...@me.com> 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.