[system] / trunk / webwork2 / lib / WeBWorK / DB / Auth.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/DB/Auth.pm

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

Revision 337 Revision 338
34 my $package = __PACKAGE__; 34 my $package = __PACKAGE__;
35 $package =~ s/([^:]*)$/$n/; 35 $package =~ s/([^:]*)$/$n/;
36 return $package; 36 return $package;
37} 37}
38 38
39=pod
39sub connect($$$) { 40sub connect($$$) {
40 my $self = shift; 41 my $self = shift;
41 my $db = shift; 42 my $db = shift;
42 my $mode = shift; 43 my $mode = shift;
43 return if defined $self->{$db."_db"}; 44 return if defined $self->{$db."_db"};
49 my $self = shift; 50 my $self = shift;
50 my $db = shift; 51 my $db = shift;
51 return unless defined $self->{$db."_db"}; 52 return unless defined $self->{$db."_db"};
52 $self->{$db."_db"}->disconnect; 53 $self->{$db."_db"}->disconnect;
53} 54}
55=cut
54 56
55# ----- 57# -----
56 58
59=pod
57sub getUsers($) { 60sub getUsers($) {
58 my $self = shift; 61 my $self = shift;
62 my @password_users, @permissions_users, @keys_users;
59 return unless $self->{password_db}->connect("ro"); 63 if ($self->{password_db}->connect("ro")) {
60 my @password_users = keys %{$self->{password_db}->hashRef}; 64 @password_users = keys %{$self->{password_db}->hashRef};
61 $self->{password_db}->disconnect; 65 $self->{password_db}->disconnect;
66 }
62 return unless $self->{permissions_db}->connect("ro"); 67 if ($self->{permissions_db}->connect("ro")) {
63 my @permissions_users = keys %{$self->{permissions_db}->hashRef}; 68 @permissions_users = keys %{$self->{permissions_db}->hashRef};
64 $self->{permissions_db}->disconnect; 69 $self->{permissions_db}->disconnect;
65 return unless $self->{keys_db}->connect("ro"); 70 }
71 if ($self->{keys_db}->connect("ro")) {
66 my @keys_users = keys %{$self->{keys_db}->hashRef}; 72 @keys_users = keys %{$self->{keys_db}->hashRef};
67 $self->{keys_db}->disconnect; 73 $self->{keys_db}->disconnect;
74 }
68 my %all_users; 75 my %all_users;
69 $all_users{$_}++ foreach (@password_users, @permissions_users, @keys_users); 76 foreach (@password_users, @permissions_users, @keys_users) {
77 $all_users{$_}++;
78 }
70 return keys %all_users; 79 return keys %all_users;
71} 80}
81=cut
72 82
73# ----- 83# -----
74 84
75sub getPassword($$) { 85sub getPassword($$) {
76 my $self = shift; 86 my $self = shift;
93sub verifyPassword($$$) { 103sub verifyPassword($$$) {
94 my $self = shift; 104 my $self = shift;
95 my $user = shift; 105 my $user = shift;
96 my $password = shift; 106 my $password = shift;
97 my $real_password = $self->getPassword($user); 107 my $real_password = $self->getPassword($user);
108 return unless defined $real_password;
98 $password = crypt $password, $real_password; 109 $password = crypt $password, $real_password;
99 return $password eq $real_password; 110 return $password eq $real_password;
100} 111}
101 112
102sub deletePassword($$) { 113sub deletePassword($$) {

Legend:
Removed from v.337  
changed lines
  Added in v.338

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9