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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-03-10 14:08:15 UTC
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090310140815-bmsnfeez0sr77g2h
Updated exercise_service to make use of the new deletion methods
for exercises and tests.

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.util
28
29
import ivle.pulldown_subj
29
30
import ivle.webapp.security
30
31
from ivle.auth import authenticate, AuthError
43
44
        fields = req.get_fieldstorage()
44
45
        nexturl = fields.getfirst('url')
45
46
 
46
 
        # XXX Warning that Internet Explorer is unsupported
47
 
        # Test if the user is in Internet Explorer
48
 
        try:
49
 
            useragent = req.headers_in['User-Agent']
50
 
            # A bit of very basic UA string detection
51
 
            ctx['msie'] = ('MSIE' in useragent
52
 
                           and 'AppleWebKit' not in useragent
53
 
                           and 'Gecko' not in useragent
54
 
                           and 'Opera' not in useragent)
55
 
        except KeyError:
56
 
            ctx['msie'] = False
57
 
 
58
47
        if nexturl is None:
59
48
            nexturl = '/'
60
49
 
73
62
        else:
74
63
            query_string = '?url=' + urllib.quote(nexturl, safe="/~")
75
64
 
76
 
        ctx['path'] = req.make_path('+login') + query_string
 
65
        ctx['path'] = ivle.util.make_path('+login') + query_string
77
66
 
78
67
        # If this succeeds, the user is invalid.
79
68
        user = ivle.webapp.security.get_user_details(req)
84
73
                # if you are not planning to display a ToS page - the ToS
85
74
                # acceptance process actually calls usrmgt to create the user
86
75
                # jails and related stuff.
87
 
                req.throw_redirect(req.make_path('+tos') + query_string)
 
76
                req.throw_redirect(ivle.util.make_path('+tos') + query_string)
88
77
            elif user.state == "pending":
89
78
                # FIXME: this isn't quite the right answer, but it
90
79
                # should be more robust in the short term.
113
102
                else:
114
103
                    user = None
115
104
                    try:
116
 
                        # Username is case insensitive
117
 
                        user = authenticate.authenticate(req.config, req.store,
118
 
                                    username.value.lower(), password.value)
 
105
                        user = authenticate.authenticate(req.store,
 
106
                                    username.value, password.value)
119
107
                    except AuthError, msg:
120
108
                        badlogin = msg
121
109
                    if user is None:
140
128
                                          plugin.cookies[cookie](user), path='/'))
141
129
 
142
130
                        # Add any new enrolments.
143
 
                        ivle.pulldown_subj.enrol_user(req.config, req.store, user)
 
131
                        ivle.pulldown_subj.enrol_user(req.store, user)
144
132
                        req.store.commit()
145
133
 
146
134
                        req.throw_redirect(nexturl)
164
152
        if req.method == "POST":
165
153
            req.logout()
166
154
        else:
167
 
            ctx['path'] =  req.make_path('+logout')
 
155
            ctx['path'] =  ivle.util.make_path('+logout')