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

« back to all changes in this revision

Viewing changes to ivle/dispatch/login.py

  • Committer: me at id
  • Date: 2009-01-15 01:06:33 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1144
ivle.auth.* now uses Storm, and not ivle.(db|user). This changes the interface
    somewhat (lots of things take a 'store' argument), so fix callers.

ivle.db: Remove user_authenticate; it's now a method of ivle.database.User.

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:
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)