Lines 1763-1779
sub checkpw {
Link Here
|
1763 |
|
1763 |
|
1764 |
my @return; |
1764 |
my @return; |
1765 |
my $patron = Koha::Patrons->find({ userid => $userid }); |
1765 |
my $patron = Koha::Patrons->find({ userid => $userid }); |
|
|
1766 |
my $check_internal_as_fallback = 0; |
1767 |
my $passwd_ok = 0; |
1768 |
# Note: checkpw_* routines returns: |
1769 |
# 1 if auth is ok |
1770 |
# 0 if auth is nok |
1771 |
# -1 if user bind failed (LDAP only) |
1766 |
|
1772 |
|
1767 |
if ( $patron and $patron->account_locked ) { |
1773 |
if ( $patron and $patron->account_locked ) { |
1768 |
@return = (0); |
1774 |
# Nothing to check, account is locked |
1769 |
} elsif ($ldap) { |
1775 |
} elsif ($ldap) { |
1770 |
$debug and print STDERR "## checkpw - checking LDAP\n"; |
1776 |
$debug and print STDERR "## checkpw - checking LDAP\n"; |
1771 |
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH |
1777 |
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH |
1772 |
if ( $retval ) { |
1778 |
if ( $retval ) { |
1773 |
@return = ( $retval, $retcard, $retuserid ); |
1779 |
@return = ( $retval, $retcard, $retuserid ); |
1774 |
} else { |
|
|
1775 |
@return = (0); |
1776 |
} |
1780 |
} |
|
|
1781 |
$passwd_ok = 1 if $retval == 1; |
1782 |
$check_internal_as_fallback = 1 if $retval == -1; |
1777 |
|
1783 |
|
1778 |
} elsif ( $cas && $query && $query->param('ticket') ) { |
1784 |
} elsif ( $cas && $query && $query->param('ticket') ) { |
1779 |
$debug and print STDERR "## checkpw - checking CAS\n"; |
1785 |
$debug and print STDERR "## checkpw - checking CAS\n"; |
Lines 1784-1792
sub checkpw {
Link Here
|
1784 |
my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query, $type ); # EXTERNAL AUTH |
1790 |
my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query, $type ); # EXTERNAL AUTH |
1785 |
if ( $retval ) { |
1791 |
if ( $retval ) { |
1786 |
@return = ( $retval, $retcard, $retuserid ); |
1792 |
@return = ( $retval, $retcard, $retuserid ); |
1787 |
} else { |
|
|
1788 |
@return = (0); |
1789 |
} |
1793 |
} |
|
|
1794 |
$passwd_ok = $retval; |
1790 |
} |
1795 |
} |
1791 |
|
1796 |
|
1792 |
# If we are in a shibboleth session (shibboleth is enabled, and a shibboleth match attribute is present) |
1797 |
# If we are in a shibboleth session (shibboleth is enabled, and a shibboleth match attribute is present) |
Lines 1805-1827
sub checkpw {
Link Here
|
1805 |
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
1810 |
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
1806 |
if ( $retval ) { |
1811 |
if ( $retval ) { |
1807 |
@return = ( $retval, $retcard, $retuserid ); |
1812 |
@return = ( $retval, $retcard, $retuserid ); |
1808 |
} else { |
|
|
1809 |
@return = (0); |
1810 |
} |
1813 |
} |
|
|
1814 |
$passwd_ok = $retval; |
1811 |
} |
1815 |
} |
|
|
1816 |
} else { |
1817 |
$check_internal_as_fallback = 1; |
1812 |
} |
1818 |
} |
1813 |
|
1819 |
|
1814 |
# INTERNAL AUTH |
1820 |
# INTERNAL AUTH |
1815 |
@return = checkpw_internal( $dbh, $userid, $password, $no_set_userenv) unless @return; |
1821 |
@return = checkpw_internal( $dbh, $userid, $password, $no_set_userenv) if $check_internal_as_fallback; |
1816 |
|
1822 |
|
1817 |
if ( $return[0] == 0 ) { |
1823 |
unless ( $passwd_ok ) { # Auth failed |
1818 |
$patron->update({ login_attempts => $patron->login_attempts + 1 }) if $patron; |
1824 |
$patron->update({ login_attempts => $patron->login_attempts + 1 }) if $patron; |
1819 |
} elsif ( $return[0] == 1 ) { |
1825 |
} elsif ( $patron ) { |
1820 |
if ( $patron ) { |
1826 |
# FIXME Koha::Object->update should return a Koha::Object to allow chaining |
1821 |
# FIXME Koha::Object->update should return a Koha::Object to allow chaining |
1827 |
$patron->update({ login_attempts => 0 }); |
1822 |
$patron->update({ login_attempts => 0 }); |
1828 |
$patron->store; |
1823 |
$patron->store; |
|
|
1824 |
} |
1825 |
} |
1829 |
} |
1826 |
return @return; |
1830 |
return @return; |
1827 |
} |
1831 |
} |
1828 |
- |
|
|