| 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: webwork-modperl/lib/WeBWorK/Authen.pm,v 1.29 2004/02/05 00:05:11 sh002i Exp $ |
4 | # $CVSHeader: webwork2/lib/WeBWorK/Authen.pm,v 1.30 2004/03/15 20:17: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. |
| … | |
… | |
| 435 | # One time, I deleted it, and my mother broke her back, my cat died, and |
435 | # One time, I deleted it, and my mother broke her back, my cat died, and |
| 436 | # the Pope got a tummy ache. When I replaced the line, I received eternal |
436 | # the Pope got a tummy ache. When I replaced the line, I received eternal |
| 437 | # salvation and a check for USD 500. |
437 | # salvation and a check for USD 500. |
| 438 | } |
438 | } |
| 439 | |
439 | |
|
|
440 | sub verifyProctor ($) { |
|
|
441 | my $self = shift(); |
|
|
442 | my $r = $self->{r}; |
|
|
443 | my $ce = $r->ce; |
|
|
444 | my $db = $r->db; |
|
|
445 | |
|
|
446 | my $user = $r->param('user'); |
|
|
447 | my $proctorUser = $r->param('proctor_user'); |
|
|
448 | my $proctorPasswd = $r->param('proctor_passwd'); |
|
|
449 | my $proctorKey = $r->param('proctor_key'); |
|
|
450 | |
|
|
451 | my $failWithoutError = 0; |
|
|
452 | my $error = ''; |
|
|
453 | |
|
|
454 | VERIFY: { |
|
|
455 | unless( ( defined($proctorUser) && $proctorUser ) or |
|
|
456 | ( defined($proctorPasswd) && $proctorPasswd ) or |
|
|
457 | ( defined($proctorKey) && $proctorKey ) ) { |
|
|
458 | $failWithoutError = 1; |
|
|
459 | last VERIFY; |
|
|
460 | } |
|
|
461 | |
|
|
462 | unless( defined($proctorUser) ) { |
|
|
463 | $error = 'Proctor username must be specified.'; |
|
|
464 | last VERIFY; |
|
|
465 | } |
|
|
466 | |
|
|
467 | my $proctorUserRecord = $db->getUser( $proctorUser ); |
|
|
468 | unless( defined( $proctorUserRecord ) ) { |
|
|
469 | $error = "There is no proctor account for $proctorUser in this course"; |
|
|
470 | last VERIFY; |
|
|
471 | } |
|
|
472 | |
|
|
473 | unless( ! defined( $proctorUserRecord->status() ) || |
|
|
474 | $proctorUserRecord->status() eq 'C' ) { |
|
|
475 | $error = "Proctor user $proctorUser does not have a valid status " . |
|
|
476 | "in this course."; |
|
|
477 | last VERIFY; |
|
|
478 | } |
|
|
479 | |
|
|
480 | if ( $proctorKey ) { |
|
|
481 | $r->param( 'proctor_password', '' ); |
|
|
482 | |
|
|
483 | if ( $self->checkKey("$user,$proctorUser", $proctorKey) ) { |
|
|
484 | last VERIFY; |
|
|
485 | } else { |
|
|
486 | $error = "Invalid or expired proctor session key."; |
|
|
487 | last VERIFY; |
|
|
488 | } |
|
|
489 | } |
|
|
490 | |
|
|
491 | if ( $proctorPasswd ) { |
|
|
492 | |
|
|
493 | if ( $self->checkPassword( $proctorUser, $proctorPasswd ) ) { |
|
|
494 | my $newKeyObject = $self->generateKey( "$user,$proctorUser" ); |
|
|
495 | $r->param('proctor_passwd', ''); |
|
|
496 | |
|
|
497 | eval{ $db->deleteKey( "$user,$proctorUser" ); }; |
|
|
498 | $db->addKey($newKeyObject); |
|
|
499 | |
|
|
500 | $r->param('proctor_key', $newKeyObject->key()); |
|
|
501 | |
|
|
502 | last VERIFY; |
|
|
503 | } else { |
|
|
504 | $error = 'Incorrect proctor username or password.'; |
|
|
505 | last VERIFY; |
|
|
506 | } |
|
|
507 | } |
|
|
508 | } |
|
|
509 | |
|
|
510 | if ( defined($error) && $error ) { |
|
|
511 | $r->notes("authen_error", $error); |
|
|
512 | return 0; |
|
|
513 | |
|
|
514 | } elsif ( $failWithoutError ) { |
|
|
515 | return 0; |
|
|
516 | |
|
|
517 | } else { |
|
|
518 | return 1; |
|
|
519 | } |
|
|
520 | critical($r); # where does critical() come from? |
|
|
521 | } |
|
|
522 | |
| 440 | 1; |
523 | 1; |
| 441 | |
524 | |
| 442 | __END__ |
525 | __END__ |
| 443 | |
526 | |
| 444 | =head1 AUTHOR |
527 | =head1 AUTHOR |