~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-04 03:47:10 UTC
  • Revision ID: grantw@unimelb.edu.au-20090304034710-lxyq8gggryfuwqbp
Only redirect +login for logged in users if the method is not POST. We do this
to allow people to use their browser's history to get to a login form, and log
in again. It's also useful for strange people who like to send POST requests
themselves.

Fixes Google Code issue 115.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        if nexturl is None:
48
48
            nexturl = '/'
49
49
 
50
 
        # 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.
51
54
        # Note that req.user is None even if we are 'logged in', if the user is
52
 
        # invalid.
53
 
        if req.user is not None:
 
55
        # invalid (state != enabled, or expired).
 
56
        if req.method != "POST" and req.user is not None:
54
57
            req.throw_redirect(nexturl)
55
58
 
56
59
        # Don't give any URL if we want /.