6 use Scalar::Util qw(weaken);
8 use SL::Auth::Constants qw(:all);
9 use SL::Auth::Password;
13 $main::lxdebug->enter_sub();
18 $self->{auth} = shift;
23 $main::lxdebug->leave_sub();
29 $main::lxdebug->enter_sub();
35 my $dbh = $self->{auth}->dbconnect();
38 $main::lxdebug->leave_sub();
42 my $query = qq|SELECT password FROM auth."user" WHERE login = ?|;
43 my ($stored_password) = $dbh->selectrow_array($query, undef, $login);
45 my ($algorithm, $algorithm2);
47 # Empty password hashes in the database mean just that -- empty
48 # passwords. Hash it for easier comparison.
49 $stored_password = SL::Auth::Password->hash(password => $stored_password) unless $stored_password;
50 ($algorithm, $stored_password) = SL::Auth::Password->parse($stored_password);
51 ($algorithm2, $password) = SL::Auth::Password->parse(SL::Auth::Password->hash_if_unhashed(password => $password, algorithm => $algorithm, login => $login));
53 $main::lxdebug->leave_sub();
55 return $password eq $stored_password ? OK : ERR_PASSWORD;
58 sub can_change_password {
62 sub requires_cleartext_password {
67 $main::lxdebug->enter_sub();
72 my $is_crypted = shift;
74 my $dbh = $self->{auth}->dbconnect();
77 $main::lxdebug->leave_sub();
81 $password = SL::Auth::Password->hash(password => $password) unless $is_crypted;
83 do_query($main::form, $dbh, qq|UPDATE auth."user" SET password = ? WHERE login = ?|, $password, $login);
87 $main::lxdebug->leave_sub();