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

« back to all changes in this revision

Viewing changes to ivle/dispatch/login.py

  • Committer: William Grant
  • Date: 2009-01-20 01:12:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090120011232-mvxq6n1p8e0pq5z2
ivle.db: insert_problem_attempt and write_problem_save now take a user object,
    not a login, so they don't need to call get_user_loginid. Thus we also
    remove get_user_login_id.
www/apps/tutorialservice: Call the two functions with req.user, not
    req.user.login.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
# Provides services for checking logins and presenting the login page.
23
23
import os
24
 
import time
 
24
import datetime
25
25
 
26
26
from mod_python import Session
27
27
 
28
28
import ivle.conf
29
29
from ivle import (util, caps, forumutil)
30
 
from ivle.auth import authenticate
 
30
from ivle.auth import authenticate, AuthError
31
31
import ivle.database
32
 
from ivle.auth import AuthError
33
32
 
34
33
def login(req):
35
34
    """Determines whether the user is logged in or not (looking at sessions),
72
71
                badlogin = "No password supplied."
73
72
            else:
74
73
                try:
75
 
                    user = \
76
 
                        authenticate.authenticate(username.value, password.value)
 
74
                    user = authenticate.authenticate(req.store,
 
75
                                username.value, password.value)
77
76
                except AuthError, msg:
78
77
                    badlogin = msg
79
78
                if user is None:
80
79
                    # Must have got an error. Do not authenticate.
81
80
                    pass
82
 
                elif user.pass_expired():
 
81
                elif user.password_expired:
83
82
                    badlogin = "Your password has expired."
84
 
                elif user.acct_expired():
 
83
                elif user.account_expired:
85
84
                    badlogin = "Your account has expired."
86
85
                else:
87
86
                    # Success - Set the session and redirect to avoid POSTDATA
88
87
                    session = req.get_session()
89
88
                    session['login'] = user.login
90
89
                    session.save()
91
 
                    user.last_login = time.localtime()
 
90
                    user.last_login = datetime.datetime.now()
92
91
                    req.store.commit()
93
92
                    req.add_cookie(forumutil.make_forum_cookie(user))
94
93
                    req.throw_redirect(req.uri)