|
Lines 1965-1987
sub checkpw {
Link Here
|
| 1965 |
my $shib_login = $shib ? get_login_shib() : undef; |
1965 |
my $shib_login = $shib ? get_login_shib() : undef; |
| 1966 |
|
1966 |
|
| 1967 |
my @return; |
1967 |
my @return; |
| 1968 |
my $patron; |
|
|
| 1969 |
if ( defined $userid ) { |
| 1970 |
$patron = Koha::Patrons->find( { userid => $userid } ); |
| 1971 |
$patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; |
| 1972 |
} |
| 1973 |
my $check_internal_as_fallback = 0; |
1968 |
my $check_internal_as_fallback = 0; |
| 1974 |
my $passwd_ok = 0; |
1969 |
my $passwd_ok = 0; |
|
|
1970 |
my $patron; |
| 1971 |
|
| 1975 |
|
1972 |
|
| 1976 |
# Note: checkpw_* routines returns: |
1973 |
# Note: checkpw_* routines returns: |
| 1977 |
# 1 if auth is ok |
1974 |
# 1 if auth is ok |
| 1978 |
# 0 if auth is nok |
1975 |
# 0 if auth is nok |
| 1979 |
# -1 if user bind failed (LDAP only) |
1976 |
# -1 if user bind failed (LDAP only) |
| 1980 |
|
1977 |
|
| 1981 |
if ( $patron and ( $patron->account_locked ) ) { |
1978 |
if ( $ldap && defined($password) ) { |
| 1982 |
|
|
|
| 1983 |
# Nothing to check, account is locked |
| 1984 |
} elsif ( $ldap && defined($password) ) { |
| 1985 |
my ( $retval, $retcard, $retuserid ); |
1979 |
my ( $retval, $retcard, $retuserid ); |
| 1986 |
( $retval, $retcard, $retuserid, $patron ) = checkpw_ldap(@_); # EXTERNAL AUTH |
1980 |
( $retval, $retcard, $retuserid, $patron ) = checkpw_ldap(@_); # EXTERNAL AUTH |
| 1987 |
if ( $retval == 1 ) { |
1981 |
if ( $retval == 1 ) { |
|
Lines 1995-2001
sub checkpw {
Link Here
|
| 1995 |
# In case of a CAS authentication, we use the ticket instead of the password |
1989 |
# In case of a CAS authentication, we use the ticket instead of the password |
| 1996 |
my $ticket = $query->param('ticket'); |
1990 |
my $ticket = $query->param('ticket'); |
| 1997 |
$query->delete('ticket'); # remove ticket to come back to original URL |
1991 |
$query->delete('ticket'); # remove ticket to come back to original URL |
| 1998 |
my ( $retval, $retcard, $retuserid, $cas_ticket, $patron ) = |
1992 |
my ( $retval, $retcard, $retuserid, $cas_ticket ); |
|
|
1993 |
( $retval, $retcard, $retuserid, $cas_ticket, $patron ) = |
| 1999 |
checkpw_cas( $ticket, $query, $type ); # EXTERNAL AUTH |
1994 |
checkpw_cas( $ticket, $query, $type ); # EXTERNAL AUTH |
| 2000 |
if ($retval) { |
1995 |
if ($retval) { |
| 2001 |
@return = ( $retval, $retcard, $retuserid, $patron, $cas_ticket ); |
1996 |
@return = ( $retval, $retcard, $retuserid, $patron, $cas_ticket ); |
|
Lines 2016-2022
sub checkpw {
Link Here
|
| 2016 |
|
2011 |
|
| 2017 |
# Then, we check if it matches a valid koha user |
2012 |
# Then, we check if it matches a valid koha user |
| 2018 |
if ($shib_login) { |
2013 |
if ($shib_login) { |
| 2019 |
my ( $retval, $retcard, $retuserid, $patron ) = |
2014 |
my ( $retval, $retcard, $retuserid ); |
|
|
2015 |
( $retval, $retcard, $retuserid, $patron ) = |
| 2020 |
C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
2016 |
C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
| 2021 |
if ($retval) { |
2017 |
if ($retval) { |
| 2022 |
@return = ( $retval, $retcard, $retuserid, $patron ); |
2018 |
@return = ( $retval, $retcard, $retuserid, $patron ); |
|
Lines 2027-2046
sub checkpw {
Link Here
|
| 2027 |
$check_internal_as_fallback = 1; |
2023 |
$check_internal_as_fallback = 1; |
| 2028 |
} |
2024 |
} |
| 2029 |
|
2025 |
|
|
|
2026 |
if ( $check_internal_as_fallback ){ |
| 2030 |
# INTERNAL AUTH |
2027 |
# INTERNAL AUTH |
| 2031 |
if ($check_internal_as_fallback) { |
|
|
| 2032 |
@return = checkpw_internal( $userid, $password, $no_set_userenv ); |
2028 |
@return = checkpw_internal( $userid, $password, $no_set_userenv ); |
| 2033 |
push( @return, $patron ); |
|
|
| 2034 |
$passwd_ok = 1 if $return[0] > 0; # 1 or 2 |
2029 |
$passwd_ok = 1 if $return[0] > 0; # 1 or 2 |
|
|
2030 |
$patron = Koha::Patrons->find({ cardnumber => $return[1] }) if $passwd_ok; |
| 2031 |
push @return, $patron if $patron; |
| 2032 |
} |
| 2033 |
|
| 2034 |
if ( defined $userid && !$patron ) { |
| 2035 |
$patron = Koha::Patrons->find( { userid => $userid } ); |
| 2036 |
$patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; |
| 2037 |
push @return, $patron if $check_internal_as_fallback; |
| 2035 |
} |
2038 |
} |
| 2036 |
|
2039 |
|
| 2037 |
if ($patron) { |
2040 |
if ($patron) { |
| 2038 |
if ($passwd_ok) { |
2041 |
if( $patron->account_locked ){ |
|
|
2042 |
@return = (); |
| 2043 |
} elsif ($passwd_ok) { |
| 2039 |
$patron->update( { login_attempts => 0 } ); |
2044 |
$patron->update( { login_attempts => 0 } ); |
| 2040 |
if ( $patron->password_expired ) { |
2045 |
if ( $patron->password_expired ) { |
| 2041 |
@return = ( -2, $patron ); |
2046 |
@return = ( -2, $patron ); |
| 2042 |
} |
2047 |
} |
| 2043 |
} elsif ( !$patron->account_locked ) { |
2048 |
} else { |
| 2044 |
$patron->update( { login_attempts => $patron->login_attempts + 1 } ); |
2049 |
$patron->update( { login_attempts => $patron->login_attempts + 1 } ); |
| 2045 |
} |
2050 |
} |
| 2046 |
} |
2051 |
} |