Lines 1982-2004
sub checkpw {
Link Here
|
1982 |
my $shib_login = $shib ? get_login_shib() : undef; |
1982 |
my $shib_login = $shib ? get_login_shib() : undef; |
1983 |
|
1983 |
|
1984 |
my @return; |
1984 |
my @return; |
1985 |
my $patron; |
|
|
1986 |
if ( defined $userid ) { |
1987 |
$patron = Koha::Patrons->find( { userid => $userid } ); |
1988 |
$patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; |
1989 |
} |
1990 |
my $check_internal_as_fallback = 0; |
1985 |
my $check_internal_as_fallback = 0; |
1991 |
my $passwd_ok = 0; |
1986 |
my $passwd_ok = 0; |
|
|
1987 |
my $patron; |
1988 |
|
1992 |
|
1989 |
|
1993 |
# Note: checkpw_* routines returns: |
1990 |
# Note: checkpw_* routines returns: |
1994 |
# 1 if auth is ok |
1991 |
# 1 if auth is ok |
1995 |
# 0 if auth is nok |
1992 |
# 0 if auth is nok |
1996 |
# -1 if user bind failed (LDAP only) |
1993 |
# -1 if user bind failed (LDAP only) |
1997 |
|
1994 |
|
1998 |
if ( $patron and ( $patron->account_locked ) ) { |
1995 |
if ( $ldap && defined($password) ) { |
1999 |
|
|
|
2000 |
# Nothing to check, account is locked |
2001 |
} elsif ( $ldap && defined($password) ) { |
2002 |
my ( $retval, $retcard, $retuserid ); |
1996 |
my ( $retval, $retcard, $retuserid ); |
2003 |
( $retval, $retcard, $retuserid, $patron ) = checkpw_ldap(@_); # EXTERNAL AUTH |
1997 |
( $retval, $retcard, $retuserid, $patron ) = checkpw_ldap(@_); # EXTERNAL AUTH |
2004 |
if ( $retval == 1 ) { |
1998 |
if ( $retval == 1 ) { |
Lines 2012-2018
sub checkpw {
Link Here
|
2012 |
# In case of a CAS authentication, we use the ticket instead of the password |
2006 |
# In case of a CAS authentication, we use the ticket instead of the password |
2013 |
my $ticket = $query->param('ticket'); |
2007 |
my $ticket = $query->param('ticket'); |
2014 |
$query->delete('ticket'); # remove ticket to come back to original URL |
2008 |
$query->delete('ticket'); # remove ticket to come back to original URL |
2015 |
my ( $retval, $retcard, $retuserid, $cas_ticket, $patron ) = |
2009 |
my ( $retval, $retcard, $retuserid, $cas_ticket ); |
|
|
2010 |
( $retval, $retcard, $retuserid, $cas_ticket, $patron ) = |
2016 |
checkpw_cas( $ticket, $query, $type ); # EXTERNAL AUTH |
2011 |
checkpw_cas( $ticket, $query, $type ); # EXTERNAL AUTH |
2017 |
if ($retval) { |
2012 |
if ($retval) { |
2018 |
@return = ( $retval, $retcard, $retuserid, $patron, $cas_ticket ); |
2013 |
@return = ( $retval, $retcard, $retuserid, $patron, $cas_ticket ); |
Lines 2033-2039
sub checkpw {
Link Here
|
2033 |
|
2028 |
|
2034 |
# Then, we check if it matches a valid koha user |
2029 |
# Then, we check if it matches a valid koha user |
2035 |
if ($shib_login) { |
2030 |
if ($shib_login) { |
2036 |
my ( $retval, $retcard, $retuserid, $patron ) = |
2031 |
my ( $retval, $retcard, $retuserid ); |
|
|
2032 |
( $retval, $retcard, $retuserid, $patron ) = |
2037 |
C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
2033 |
C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
2038 |
if ($retval) { |
2034 |
if ($retval) { |
2039 |
@return = ( $retval, $retcard, $retuserid, $patron ); |
2035 |
@return = ( $retval, $retcard, $retuserid, $patron ); |
Lines 2044-2063
sub checkpw {
Link Here
|
2044 |
$check_internal_as_fallback = 1; |
2040 |
$check_internal_as_fallback = 1; |
2045 |
} |
2041 |
} |
2046 |
|
2042 |
|
|
|
2043 |
if ( $check_internal_as_fallback ){ |
2047 |
# INTERNAL AUTH |
2044 |
# INTERNAL AUTH |
2048 |
if ($check_internal_as_fallback) { |
|
|
2049 |
@return = checkpw_internal( $userid, $password, $no_set_userenv ); |
2045 |
@return = checkpw_internal( $userid, $password, $no_set_userenv ); |
2050 |
push( @return, $patron ); |
|
|
2051 |
$passwd_ok = 1 if $return[0] > 0; # 1 or 2 |
2046 |
$passwd_ok = 1 if $return[0] > 0; # 1 or 2 |
|
|
2047 |
$patron = Koha::Patrons->find({ cardnumber => $return[1] }) if $passwd_ok; |
2048 |
push @return, $patron if $patron; |
2049 |
} |
2050 |
|
2051 |
if ( defined $userid && !$patron ) { |
2052 |
$patron = Koha::Patrons->find( { userid => $userid } ); |
2053 |
$patron = Koha::Patrons->find( { cardnumber => $userid } ) unless $patron; |
2054 |
push @return, $patron if $check_internal_as_fallback; |
2052 |
} |
2055 |
} |
2053 |
|
2056 |
|
2054 |
if ($patron) { |
2057 |
if ($patron) { |
2055 |
if ($passwd_ok) { |
2058 |
if( $patron->account_locked ){ |
|
|
2059 |
@return = (); |
2060 |
} elsif ($passwd_ok) { |
2056 |
$patron->update( { login_attempts => 0 } ); |
2061 |
$patron->update( { login_attempts => 0 } ); |
2057 |
if ( $patron->password_expired ) { |
2062 |
if ( $patron->password_expired ) { |
2058 |
@return = ( -2, $patron ); |
2063 |
@return = ( -2, $patron ); |
2059 |
} |
2064 |
} |
2060 |
} elsif ( !$patron->account_locked ) { |
2065 |
} else { |
2061 |
$patron->update( { login_attempts => $patron->login_attempts + 1 } ); |
2066 |
$patron->update( { login_attempts => $patron->login_attempts + 1 } ); |
2062 |
} |
2067 |
} |
2063 |
} |
2068 |
} |