[system] / branches / rel-2-4-dev / webwork-modperl / lib / WeBWorK.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-4-dev/webwork-modperl/lib/WeBWorK.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3598 Revision 3743
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.74 2005/08/17 16:05:48 sh002i Exp $ 4# $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.77 2005/10/11 20:44:59 sh002i Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
221 debug("(here's the authz object: $authz)\n"); 221 debug("(here's the authz object: $authz)\n");
222 $r->authz($authz); 222 $r->authz($authz);
223 223
224 debug("...and now we can authenticate the remote user...\n"); 224 debug("...and now we can authenticate the remote user...\n");
225 my $authen = new WeBWorK::Authen($r); 225 my $authen = new WeBWorK::Authen($r);
226 $r->authen($authen);
226 my $authenOK = $authen->verify; 227 my $authenOK = $authen->verify;
227 if ($authenOK) { 228 if ($authenOK) {
228 my $userID = $r->param("user"); 229 my $userID = $r->param("user");
229 debug("Hi, $userID, glad you made it.\n"); 230 debug("Hi, $userID, glad you made it.\n");
230 231
232 $authz->setCachedUser($userID); 233 $authz->setCachedUser($userID);
233 234
234 debug("Now we deal with the effective user:\n"); 235 debug("Now we deal with the effective user:\n");
235 my $eUserID = $r->param("effectiveUser") || $userID; 236 my $eUserID = $r->param("effectiveUser") || $userID;
236 debug("userID=$userID eUserID=$eUserID\n"); 237 debug("userID=$userID eUserID=$eUserID\n");
237 # FIXME: hasPermissions does nothing with $eUserID, and lately we want it to 238 if ($userID ne $eUserID) {
238 # only accept two arguments, so we're removing $eUserID from this call. 239 debug("userID and eUserID differ... seeing if userID has 'become_student' permission.\n");
239 #my $su_authorized = $authz->hasPermissions($userID, "become_student", $eUserID);
240 my $su_authorized = $authz->hasPermissions($userID, "become_student"); 240 my $su_authorized = $authz->hasPermissions($userID, "become_student");
241 if ($su_authorized) { 241 if ($su_authorized) {
242 debug("Ok, looks like you're allowed to become $eUserID. Whoopie!\n"); 242 debug("Ok, looks like you're allowed to become $eUserID. Whoopie!\n");
243 } else { 243 } else {
244 debug("Uh oh, you're not allowed to become $eUserID. Nice try!\n"); 244 debug("Uh oh, you're not allowed to become $eUserID. Nice try!\n");
245 $eUserID = $userID; 245 #$eUserID = $userID;
246 #$r->notes("authen_error" => "You do not have permission to become another user.");
247 #$displayModule = AUTHEN_MODULE;
248 die "You are not allowed to act as another user.\n";
249 }
246 } 250 }
251
252 # set effectiveUser in case it was changed or not set to begin with
247 $r->param("effectiveUser" => $eUserID); 253 $r->param("effectiveUser" => $eUserID);
254
248 # if we're doing a proctored test, after the user has been authenticated 255 # if we're doing a proctored test, after the user has been authenticated
249 # we need to also check on the proctor. note that in the gateway quiz 256 # we need to also check on the proctor. note that in the gateway quiz
250 # module we double check this, to be sure that someone isn't taking a 257 # module we double check this, to be sure that someone isn't taking a
251 # proctored quiz but calling the unproctored ContentGenerator 258 # proctored quiz but calling the unproctored ContentGenerator
252 my $urlProducedPath = $urlPath->path(); 259 my $urlProducedPath = $urlPath->path();
253
254 if ( $urlProducedPath =~ /proctored_quiz_mode/i ) { 260 if ( $urlProducedPath =~ /proctored_quiz_mode/i ) {
255 my $procAuthOK = $authen->verifyProctor(); 261 my $procAuthOK = $authen->verifyProctor();
256 262
257 if ( $procAuthOK ) { 263 if ($procAuthOK) {
258 my $proctorUserID = $r->param("proctor_user"); 264 my $proctorUserID = $r->param("proctor_user");
259 my $proctor_authorized = 265 my $proctor_authorized = $authz->hasPermissions($proctorUserID, "proctor_quiz");
260 $authz->hasPermissions($proctorUserID,
261 "proctor_quiz", $userID);
262 if ( ! $proctor_authorized ) { 266 unless ($proctor_authorized) {
263 $r->notes("authen_error", 267 $r->notes("authen_error", "User $proctorUserID is not authorized to proctor tests in this course.");
264 "Proctor $proctorUserID is not " .
265 "authorized to proctor tests in " .
266 "this course.");
267 $displayModule = PROCTOR_AUTHEN_MODULE; 268 $displayModule = PROCTOR_AUTHEN_MODULE;
269 }
270 } else {
271 $displayModule = PROCTOR_AUTHEN_MODULE;
268 } 272 }
269
270 } else {
271 $displayModule = PROCTOR_AUTHEN_MODULE;
272 }
273 } 273 }
274
275 } else { 274 } else {
276 debug("Bad news: authentication failed!\n"); 275 debug("Bad news: authentication failed!\n");
277 $displayModule = AUTHEN_MODULE; 276 $displayModule = AUTHEN_MODULE;
278 debug("set displayModule to $displayModule\n"); 277 debug("set displayModule to $displayModule\n");
279 } 278 }

Legend:
Removed from v.3598  
changed lines
  Added in v.3743

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9