~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-03-26 05:33:03 UTC
  • mto: (1165.3.1 submissions)
  • mto: This revision was merged to the branch mainline in revision 1174.
  • Revision ID: grantw@unimelb.edu.au-20090326053303-t1wsjswhk2sl2gml
Start a submission UI in ivle.webapp.submit.

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
29
30
import ivle.webapp.security
30
31
from ivle.auth import authenticate, AuthError
31
32
from ivle.webapp.base.xhtml import XHTMLView
46
47
        if nexturl is None:
47
48
            nexturl = '/'
48
49
 
49
 
        # We are already logged in. Don't bother logging in again.
 
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.
50
54
        # Note that req.user is None even if we are 'logged in', if the user is
51
 
        # invalid.
52
 
        if req.user is not None:
 
55
        # invalid (state != enabled, or expired).
 
56
        if req.method != "POST" and req.user is not None:
53
57
            req.throw_redirect(nexturl)
54
58
 
55
59
        # Don't give any URL if we want /.
111
115
                        session = req.get_session()
112
116
                        session['login'] = user.login
113
117
                        session.save()
 
118
                        session.unlock()
114
119
                        user.last_login = datetime.datetime.now()
115
 
                        req.store.commit()
116
120
 
117
121
                        # Create cookies for plugins that might request them.
118
122
                        for plugin in req.config.plugin_index[CookiePlugin]:
123
127
                                    req.add_cookie(mod_python.Cookie.Cookie(cookie,
124
128
                                          plugin.cookies[cookie](user), path='/'))
125
129
 
 
130
                        # Add any new enrolments.
 
131
                        ivle.pulldown_subj.enrol_user(req.store, user)
 
132
                        req.store.commit()
 
133
 
126
134
                        req.throw_redirect(nexturl)
127
135
 
128
136
                # We didn't succeed.