~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 06:10:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:503
user.py: Added acct_expired and pass_expired methods.
login.py: Removed has_expired function (now we put it inside the class)
    and called those methods instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from common import (util, db, caps, forumutil)
29
29
from auth import authenticate
30
30
 
31
 
def has_expired(details, field):
32
 
    """Determines whether the given expiry field indicates that
33
 
       login should be denied.
34
 
    """
35
 
    return hasattr(details, field)     \
36
 
           and details.__getattribute__(field)   \
37
 
           and time.localtime() > details.__getattribute__(field)
38
 
 
39
31
def login(req):
40
32
    """Determines whether the user is logged in or not (looking at sessions),
41
33
    and if not, presents the login page. Returns a String username, or None
77
69
                    authenticate.authenticate(username.value, password.value)
78
70
                if login_details is None:
79
71
                    badlogin = "Invalid username or password."
80
 
                elif has_expired(login_details, 'pass_exp'):
 
72
                elif login_details.pass_expired():
81
73
                    badlogin = "Your password has expired."
82
 
                elif has_expired(login_details, 'acct_exp'):
 
74
                elif login_details.acct_expired():
83
75
                    badlogin = "Your account has expired."
84
76
                else:
85
77
                    # Success - Set the session and redirect to avoid POSTDATA