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

« back to all changes in this revision

Viewing changes to www/apps/userservice/__init__.py

  • Committer: mattgiuca
  • Date: 2008-02-19 06:51:25 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:505
dispatch.html, consoleservice, userservice, interpret:
    Replaced use of session with use of "req.user" object.
    Most of these no longer need to use session at all anymore.
    Those that do do so correctly ("user" field).
This unbreaks the build.

cgirequest: Sets "user" in CGIRequest object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
        # Get the arguments for usermgt.activate_user from the session
165
165
        # (The user must have already logged in to use this app)
166
166
        args = {
167
 
            "login": req.username,
 
167
            "login": req.user.login,
168
168
        }
169
169
        msg = {'activate_user': args}
170
170
 
171
171
        response = chat.chat(usrmgt_host, usrmgt_port, msg, usrmgt_magic,
172
172
            decode = False)
173
173
        # Write to the user's session to allow them to be activated
 
174
        req.user.state = "enabled"
174
175
        session = req.get_session()
175
 
        session['state'] = "enabled"
 
176
        session['user'] = req.user
176
177
        session.save()
177
178
        # Write the response
178
179
        req.content_type = "text/plain"
191
192
    This does not create the user's jail, just an entry in the database which
192
193
    allows the user to accept an agreement.
193
194
    """
194
 
    session = req.get_session()
195
195
    if req.method != "POST":
196
196
        req.throw_error(req.HTTP_BAD_REQUEST)
197
 
    # Check if this user has CAP_CREATEUSER
198
 
    if not session['role'].hasCap(caps.CAP_UPDATEUSER):
 
197
    # Check if this user has CAP_UPDATEUSER
 
198
    if not req.user.hasCap(caps.CAP_UPDATEUSER):
199
199
        req.throw_error(req.HTTP_FORBIDDEN)
200
200
 
201
201
    # Make a dict of fields to create
236
236
    This can be done in a limited form by any user, on their own account,
237
237
    or with full powers by a user with CAP_UPDATEUSER on any account.
238
238
    """
239
 
    session = req.get_session()
240
239
    if req.method != "POST":
241
240
        req.throw_error(req.HTTP_BAD_REQUEST)
242
241
 
243
242
    # Only give full powers if this user has CAP_UPDATEUSER
244
 
    fullpowers = session['role'].hasCap(caps.CAP_UPDATEUSER)
 
243
    fullpowers = req.user.hasCap(caps.CAP_UPDATEUSER)
245
244
    # List of fields that may be changed
246
245
    fieldlist = (update_user_fields_admin if fullpowers
247
246
        else update_user_fields_anyone)
266
265
    # Get the arguments for usermgt.create_user from the session
267
266
    # (The user must have already logged in to use this app)
268
267
    args = {
269
 
        "login": req.username,
 
268
        "login": req.user.login,
270
269
        "update": update,
271
270
    }
272
271
    msg = {'update_user': args}