[system] / branches / rel-2-3-dev / webwork2 / lib / WeBWorK / Authen.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-3-dev/webwork2/lib/WeBWorK/Authen.pm

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

Revision 1681 Revision 1682
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$ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/Authen.pm,v 1.20 2003/12/09 01:12:30 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.
31 my $self = {}; 31 my $self = {};
32 ($self->{r}, $self->{ce}, $self->{db}) = @_; 32 ($self->{r}, $self->{ce}, $self->{db}) = @_;
33 bless $self, $class; 33 bless $self, $class;
34 return $self; 34 return $self;
35} 35}
36
37# um, this isn't used. move it to Utils?
38#sub generatePassword($$$) {
39# my ($self, $userID, $clearPassword) = @_;
40# my $salt = join("", ('.','/','0'..'9','A'..'Z','a'..'z')[rand 64, rand 64]);
41# my $cryptPassword = crypt($clearPassword, $salt);
42# return WeBWorK::DB::Record::Password->new(user_id=>$userID, password=>$password);
43#}
44 36
45sub checkPassword($$$) { 37sub checkPassword($$$) {
46 my ($self, $userID, $possibleClearPassword) = @_; 38 my ($self, $userID, $possibleClearPassword) = @_;
47 my $Password = $self->{db}->getPassword($userID); # checked 39 my $Password = $self->{db}->getPassword($userID); # checked
48 return 0 unless defined $Password; 40 return 0 unless defined $Password;
94 $self->{db}->deleteKey($userID); 86 $self->{db}->deleteKey($userID);
95 return 0; 87 return 0;
96 } 88 }
97} 89}
98 90
99# verify will return 1 if the person is who they say the are. 91# verify will return 1 if the person is who they say the are. If the
100# If the verification failed because of of invalid authentication data, 92# verification failed because of of invalid authentication data, a note will be
101# a note will be written in the request explaining why it failed. 93# written in the request explaining why it failed. If the request failed because
102# If the request failed because no authentication data was provided, however, 94# no authentication data was provided, however, no note will be written, as this
103# no note will be written, as this is expected to happen whenever someone 95# is expected to happen whenever someone types in a URL manually, and is not
104# types in a URL manually, and is not considered an error condition. 96# considered an error condition.
105sub verify($) { 97sub verify($) {
106 my $self = shift; 98 my $self = shift;
107 my $r = $self->{r}; 99 my $r = $self->{r};
108 my $ce = $self->{ce}; 100 my $ce = $self->{ce};
109 my $db = $self->{db}; 101 my $db = $self->{db};
231 # neither a key or a password were supplied. 223 # neither a key or a password were supplied.
232 $error = "You must enter a password." 224 $error = "You must enter a password."
233 } 225 }
234 226
235 if (defined $error) { 227 if (defined $error) {
228 # authentication failed, in a bad way
236 $r->notes("authen_error",$error); 229 $r->notes("authen_error",$error);
237 return 0; 230 return 0;
231 } elsif ($failWithoutError) {
232 # authentication failed, but not in a bad way
233 return 0;
238 } else { 234 } else {
239 return not $failWithoutError; 235 # autentication succeeded!
236 return 1;
240 } 237 }
241 238
242 # Whatever you do, don't delete this! 239 # Whatever you do, don't delete this!
243 critical($r); 240 critical($r);
244} 241}
247 244
248__END__ 245__END__
249 246
250=head1 AUTHOR 247=head1 AUTHOR
251 248
252Written by Dennis Lambe Jr., malsyned (at) math.rochester.edu, and Sam Hathaway, sh002i (at) math.rochester.edu. 249Written by Dennis Lambe Jr., malsyned (at) math.rochester.edu, and Sam
250Hathaway, sh002i (at) math.rochester.edu.
253 251
254=cut 252=cut

Legend:
Removed from v.1681  
changed lines
  Added in v.1682

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9