| 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.67 2004/11/02 19:58:31 sh002i Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.68 2004/11/02 20:47:35 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("set displayModule to $displayModule\n"); |
221 | debug("set displayModule to $displayModule\n"); |
| 222 | } else { |
222 | } else { |
| 223 | debug("hashDatabaseOK() returned $dbOK -- leaving displayModule as-is\n"); |
223 | debug("hashDatabaseOK() returned $dbOK -- leaving displayModule as-is\n"); |
| 224 | } |
224 | } |
| 225 | |
225 | |
|
|
226 | debug("Create an authz object (Authen needs it to check login permission)...\n"); |
|
|
227 | $authz = new WeBWorK::Authz($r, $ce, $db); |
|
|
228 | debug("(here's the authz object: $authz)\n"); |
|
|
229 | $r->authz($authz); |
|
|
230 | |
| 226 | debug("...and now we can authenticate the remote user...\n"); |
231 | debug("...and now we can authenticate the remote user...\n"); |
| 227 | my $authen = new WeBWorK::Authen($r); |
232 | my $authen = new WeBWorK::Authen($r); |
| 228 | my $authenOK = $authen->verify; |
233 | my $authenOK = $authen->verify; |
| 229 | if ($authenOK) { |
234 | if ($authenOK) { |
|
|
235 | my $userID = $r->param("user"); |
| 230 | debug("Hi, ", $r->param("user"), ", glad you made it.\n"); |
236 | debug("Hi, $userID, glad you made it.\n"); |
| 231 | |
|
|
| 232 | debug("Authentication succeeded, so it makes sense to create an authz object...\n"); |
|
|
| 233 | $authz = new WeBWorK::Authz($r, $ce, $db); |
|
|
| 234 | debug("(here's the authz object: $authz)\n"); |
|
|
| 235 | $r->authz($authz); |
|
|
| 236 | |
237 | |
| 237 | debug("Now we deal with the effective user:\n"); |
238 | debug("Now we deal with the effective user:\n"); |
| 238 | my $userID = $r->param("user"); |
|
|
| 239 | my $eUserID = $r->param("effectiveUser") || $userID; |
239 | my $eUserID = $r->param("effectiveUser") || $userID; |
| 240 | debug("userID=$userID eUserID=$eUserID\n"); |
240 | debug("userID=$userID eUserID=$eUserID\n"); |
| 241 | my $su_authorized = $authz->hasPermissions($userID, "become_student", $eUserID); |
241 | my $su_authorized = $authz->hasPermissions($userID, "become_student", $eUserID); |
| 242 | if ($su_authorized) { |
242 | if ($su_authorized) { |
| 243 | debug("Ok, looks like you're allowed to become $eUserID. Whoopie!\n"); |
243 | debug("Ok, looks like you're allowed to become $eUserID. Whoopie!\n"); |