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

« back to all changes in this revision

Viewing changes to ivle/dispatch/login.py

Move the pending/no_agreement handling into the new login machinery.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
from ivle.webapp.base.plugins import CookiePlugin
36
36
import ivle.database
37
37
 
38
 
 
39
 
# XXX: Move this elsewhere, as it's just in storage now...
40
 
def tos_stuff():
41
 
    # User is not logged in or their account is not enabled.
42
 
    if user is not None:
43
 
        # Only possible if no errors occured thus far
44
 
        if user.state == "no_agreement":
45
 
            # User has authenticated but has not accepted the TOS.
46
 
            # Present them with the TOS page.
47
 
            # First set their username for display at the top, but make sure
48
 
            # the apps tabs are not displayed
49
 
            req.user = user
50
 
            # IMPORTANT NOTE FOR HACKERS: You can't simply disable this check
51
 
            # if you are not planning to display a TOS page - the TOS
52
 
            # acceptance process actually calls usermgt to create the user
53
 
            # jails and related stuff.
54
 
            present_tos(req, user.fullname)
55
 
            return None
56
 
        elif user.state == "disabled":
57
 
            # User has authenticated but their account is disabled
58
 
            badlogin = "Your account has been disabled."
59
 
        elif user.state == "pending":
60
 
            # FIXME: this isn't quite the right answer, but it
61
 
            # should be more robust in the short term.
62
 
            session = req.get_session()
63
 
            session.invalidate()
64
 
            session.delete()
65
 
            user.state = u'no_agreement'
66
 
            req.store.commit()
67
 
            req.throw_redirect(req.uri)
68
 
 
69
38
def get_user_details(req):
70
39
    """Gets the name of the logged in user, without presenting a login box
71
40
    or attempting to authenticate.