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 $stored_password = $self->{auth}->get_stored_password($login);
37 my ($algorithm, $algorithm2);
39 # Empty password hashes in the database mean just that -- empty
40 # passwords. Hash it for easier comparison.
41 $stored_password = SL::Auth::Password->hash(password => $stored_password) unless $stored_password;
42 ($algorithm, $stored_password) = SL::Auth::Password->parse($stored_password);
43 ($algorithm2, $password) = SL::Auth::Password->parse(SL::Auth::Password->hash_if_unhashed(password => $password, algorithm => $algorithm, login => $login));
45 $main::lxdebug->leave_sub();
47 return $password eq $stored_password ? OK : ERR_PASSWORD;
50 sub can_change_password {
54 sub requires_cleartext_password {
59 $main::lxdebug->enter_sub();
64 my $is_crypted = shift;
66 my $dbh = $self->{auth}->dbconnect();
69 $main::lxdebug->leave_sub();
73 $password = SL::Auth::Password->hash(login => $login, password => $password) unless $is_crypted;
75 do_query($main::form, $dbh, qq|UPDATE auth."user" SET password = ? WHERE login = ?|, $password, $login);
79 $main::lxdebug->leave_sub();