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

« back to all changes in this revision

Viewing changes to ivle/webapp/security/views.py

  • Committer: William Grant
  • Date: 2009-02-25 23:04:11 UTC
  • Revision ID: grantw@unimelb.edu.au-20090225230411-lbdyl32ir0m3d59b
Make all of the services executable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    pass
27
27
 
28
28
import ivle.util
29
 
import ivle.pulldown_subj
30
29
import ivle.webapp.security
31
30
from ivle.auth import authenticate, AuthError
32
31
from ivle.webapp.base.xhtml import XHTMLView
47
46
        if nexturl is None:
48
47
            nexturl = '/'
49
48
 
50
 
        # We are already logged in. If it is a POST, they might be trying to
51
 
        # clobber their session with some new credentials. That's their own
52
 
        # business, so we let them do it. Otherwise, we don't bother prompting
53
 
        # and just redirect to the destination.
 
49
        # We are already logged in. Don't bother logging in again.
54
50
        # Note that req.user is None even if we are 'logged in', if the user is
55
 
        # invalid (state != enabled, or expired).
56
 
        if req.method != "POST" and req.user is not None:
 
51
        # invalid.
 
52
        if req.user is not None:
57
53
            req.throw_redirect(nexturl)
58
54
 
59
55
        # Don't give any URL if we want /.
115
111
                        session = req.get_session()
116
112
                        session['login'] = user.login
117
113
                        session.save()
118
 
                        session.unlock()
119
114
                        user.last_login = datetime.datetime.now()
 
115
                        req.store.commit()
120
116
 
121
117
                        # Create cookies for plugins that might request them.
122
118
                        for plugin in req.config.plugin_index[CookiePlugin]:
127
123
                                    req.add_cookie(mod_python.Cookie.Cookie(cookie,
128
124
                                          plugin.cookies[cookie](user), path='/'))
129
125
 
130
 
                        # Add any new enrolments.
131
 
                        ivle.pulldown_subj.enrol_user(req.store, user)
132
 
                        req.store.commit()
133
 
 
134
126
                        req.throw_redirect(nexturl)
135
127
 
136
128
                # We didn't succeed.