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 my ($algorithm, $algorithm2);
43 # Empty password hashes in the database mean just that -- empty
44 # passwords. Hash it for easier comparison.
45 $stored_password = SL::Auth::Password->hash(password => $stored_password) unless $stored_password;
46 ($algorithm, $stored_password) = SL::Auth::Password->parse($stored_password);
47 ($algorithm2, $password) = SL::Auth::Password->parse(SL::Auth::Password->hash(password => $password, algorithm => $algorithm, login => $login));
49 $main::lxdebug->leave_sub();
51 return $password eq $stored_password ? OK : ERR_PASSWORD;
54 sub can_change_password {
58 sub requires_cleartext_password {
63 $main::lxdebug->enter_sub();
68 my $is_crypted = shift;
70 my $dbh = $self->{auth}->dbconnect();
73 $main::lxdebug->leave_sub();
77 $password = SL::Auth::Password->hash(login => $login, password => $password) unless $is_crypted;
79 do_query($main::form, $dbh, qq|UPDATE auth."user" SET password = ? WHERE login = ?|, $password, $login);
83 $main::lxdebug->leave_sub();