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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2009-02-25 10:19:29 UTC
  • mfrom: (1100.1.35 new-ui)
  • Revision ID: matt.giuca@gmail.com-20090225101929-v2206kbf3lgkm1kz
*Spoiler warning: Plot or ending details follow*

Merged from new-ui branch.

IVLE top bar and top of filebrowser and console have all been made over. They
look very shiny and web 2.0!

Added image-source top-level directory with SVG source images.

Added new chrome images to ivle/webapp/coremedia/images.

Redid a lot CSS and HTML.
Every page now has an H1 at the top (common UI). Moved existing H1s to the top
of the page. Other H1s have been cleaned up (moved to H2s or restyled).
IVLE top bar has been majorly cleaned up (previously had many layered divs);
now more accessible.

Subject icon replaced with tutorial one.

The funeral for the tacky yellow and blue stylesheet will be held this Friday.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    # This needs to be importable from outside Apache.
26
26
    pass
27
27
 
28
 
import ivle.pulldown_subj
 
28
import ivle.util
29
29
import ivle.webapp.security
30
30
from ivle.auth import authenticate, AuthError
31
31
from ivle.webapp.base.xhtml import XHTMLView
46
46
        if nexturl is None:
47
47
            nexturl = '/'
48
48
 
49
 
        # We are already logged in. If it is a POST, they might be trying to
50
 
        # clobber their session with some new credentials. That's their own
51
 
        # business, so we let them do it. Otherwise, we don't bother prompting
52
 
        # and just redirect to the destination.
 
49
        # We are already logged in. Don't bother logging in again.
53
50
        # Note that req.user is None even if we are 'logged in', if the user is
54
 
        # invalid (state != enabled, or expired).
55
 
        if req.method != "POST" and req.user is not None:
 
51
        # invalid.
 
52
        if req.user is not None:
56
53
            req.throw_redirect(nexturl)
57
54
 
58
55
        # Don't give any URL if we want /.
61
58
        else:
62
59
            query_string = '?url=' + urllib.quote(nexturl, safe="/~")
63
60
 
64
 
        ctx['path'] = req.make_path('+login') + query_string
 
61
        ctx['path'] = ivle.util.make_path('+login') + query_string
65
62
 
66
63
        # If this succeeds, the user is invalid.
67
64
        user = ivle.webapp.security.get_user_details(req)
72
69
                # if you are not planning to display a ToS page - the ToS
73
70
                # acceptance process actually calls usrmgt to create the user
74
71
                # jails and related stuff.
75
 
                req.throw_redirect(req.make_path('+tos') + query_string)
 
72
                req.throw_redirect(ivle.util.make_path('+tos') + query_string)
76
73
            elif user.state == "pending":
77
74
                # FIXME: this isn't quite the right answer, but it
78
75
                # should be more robust in the short term.
101
98
                else:
102
99
                    user = None
103
100
                    try:
104
 
                        # Username is case insensitive
105
 
                        user = authenticate.authenticate(req.config, req.store,
106
 
                                    username.value.lower(), password.value)
 
101
                        user = authenticate.authenticate(req.store,
 
102
                                    username.value, password.value)
107
103
                    except AuthError, msg:
108
104
                        badlogin = msg
109
105
                    if user is None:
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.config, req.store, user)
132
 
                        req.store.commit()
133
 
 
134
126
                        req.throw_redirect(nexturl)
135
127
 
136
128
                # We didn't succeed.
152
144
        if req.method == "POST":
153
145
            req.logout()
154
146
        else:
155
 
            ctx['path'] =  req.make_path('+logout')
 
147
            ctx['path'] =  ivle.util.make_path('+logout')