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();
33 $main::lxdebug->enter_sub();
39 my $stored_password = $self->{auth}->get_stored_password($login);
41 # Empty password hashes in the database mean just that -- empty
42 # passwords. Hash it for easier comparison.
43 $stored_password = SL::Auth::Password->hash(password => $stored_password) unless $stored_password;
44 my ($algorithm) = SL::Auth::Password->parse($stored_password);
45 my $hashed_password = SL::Auth::Password->hash(password => $password, algorithm => $algorithm, login => $login, stored_password => $stored_password);
47 $main::lxdebug->leave_sub();
49 return $hashed_password eq $stored_password ? OK : ERR_PASSWORD;
52 sub can_change_password {
56 sub requires_cleartext_password {
61 $main::lxdebug->enter_sub();
66 my $is_crypted = shift;
68 my $dbh = $self->{auth}->dbconnect();
71 $main::lxdebug->leave_sub();
75 $password = SL::Auth::Password->hash(login => $login, password => $password) unless $is_crypted;
77 do_query($main::form, $dbh, qq|UPDATE auth."user" SET password = ? WHERE login = ?|, $password, $login);
81 $main::lxdebug->leave_sub();