~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/dispatch/login.py

  • Committer: mattgiuca
  • Date: 2008-02-01 08:06:30 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:376
auth/authenticate: Replaced dummy code (which always auths) with a call to the
    DB. Now correctly authenticates.
    IMPORTANT: Changed interface. Instead of returning True/False, now returns
    None or a dictionary of the login details.
    I have chased this up with all the callers (just 1).
dispatch/login.py: Reworked call to authenticate. Now handles the change
    above, and retrieves the login details. Writes all of the user's login
    fields to the browser session (see debuginfo to see the fields stored
    there).

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
            # From this point onwards, we will be showing an error message
61
61
            # if unsuccessful.
62
62
            # Authenticate
63
 
            if (password is not None and
64
 
                authenticate.authenticate(username.value, password.value)):
65
 
                # Success - Set the session and redirect to avoid POSTDATA
66
 
                session['login_name'] = username.value
67
 
                session.save()
68
 
                req.throw_redirect(req.uri)
 
63
            if password is None:
 
64
                badlogin = True
69
65
            else:
70
 
                badlogin = True
 
66
                login_details = \
 
67
                    authenticate.authenticate(username.value, password.value)
 
68
                if login_details is None:
 
69
                    badlogin = True
 
70
                else:
 
71
                    # Success - Set the session and redirect to avoid POSTDATA
 
72
                    session['login_name'] = username.value
 
73
                    session['nick'] = login_details['nick']
 
74
                    session['fullname'] = login_details['fullname']
 
75
                    session['rolenm'] = login_details['rolenm']
 
76
                    session['studentid'] = login_details['studentid']
 
77
                    session.save()
 
78
                    req.throw_redirect(req.uri)
71
79
 
72
80
    # User is not logged in. Present the login box.
73
81
    # Give a 403 Forbidden status, but present a full HTML login page