~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-19 00:54:28 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:500
db: get_user and get_users now return User objects instead of dictionaries.
    This is the major part of replacing dicts with User objects, as it
    propagates upwards.

Propagated User objects up through the following modules:
    listusers.py, dispatch.login, authenticate, userservice, forumutil
All of these now treat users as an object rather than a dict.

To save on the size of the changes so far, login still individually copies
fields over to the session (so the session does not yet store a user object;
that is the second part of this refactor).

WOO!! Revision 500 :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    """Determines whether the given expiry field indicates that
33
33
       login should be denied.
34
34
    """
35
 
    return field in details     \
36
 
           and details[field]   \
37
 
           and time.localtime() > details[field]
 
35
    return hasattr(details, field)     \
 
36
           and details.__getattribute__(field)   \
 
37
           and time.localtime() > details.__getattribute__(field)
38
38
 
39
39
def login(req):
40
40
    """Determines whether the user is logged in or not (looking at sessions),
83
83
                    badlogin = "Your account has expired."
84
84
                else:
85
85
                    # Success - Set the session and redirect to avoid POSTDATA
 
86
                    # TODO: Store the User object in session instead of
 
87
                    # individual fields
86
88
                    session['login_name'] = username.value
87
 
                    session['unixid'] = login_details['unixid']
88
 
                    session['state'] = login_details['state']
89
 
                    session['email'] = login_details['email']
90
 
                    session['nick'] = login_details['nick']
91
 
                    session['fullname'] = login_details['fullname']
92
 
                    session['role'] = caps.Role(login_details['rolenm'])
93
 
                    session['studentid'] = login_details['studentid']
 
89
                    session['unixid'] = login_details.unixid
 
90
                    session['state'] = login_details.state
 
91
                    session['email'] = login_details.email
 
92
                    session['nick'] = login_details.nick
 
93
                    session['fullname'] = login_details.fullname
 
94
                    session['role'] = login_details.role
 
95
                    session['studentid'] = login_details.studentid
94
96
                    session.save()
95
97
                    # XXX time.localtime() (a tuple of ints) is not valid for
96
98
                    # inserting as a TIMESTAMP in the DB.