|
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) |
| 1772 |
# 2 if DB user is used (internal only) |
| 1766 |
|
1773 |
|
| 1767 |
if ( $patron and $patron->account_locked ) { |
1774 |
if ( $patron and $patron->account_locked ) { |
| 1768 |
@return = (0); |
1775 |
# Nothing to check, account is locked |
| 1769 |
} elsif ($ldap) { |
1776 |
} elsif ($ldap) { |
| 1770 |
$debug and print STDERR "## checkpw - checking LDAP\n"; |
1777 |
$debug and print STDERR "## checkpw - checking LDAP\n"; |
| 1771 |
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH |
1778 |
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH |
| 1772 |
if ( $retval ) { |
1779 |
if ( $retval ) { |
| 1773 |
@return = ( $retval, $retcard, $retuserid ); |
1780 |
@return = ( $retval, $retcard, $retuserid ); |
| 1774 |
} else { |
|
|
| 1775 |
@return = (0); |
| 1776 |
} |
1781 |
} |
|
|
1782 |
$passwd_ok = 1 if $retval == 1; |
| 1783 |
$check_internal_as_fallback = 1 if $retval == -1; |
| 1777 |
|
1784 |
|
| 1778 |
} elsif ( $cas && $query && $query->param('ticket') ) { |
1785 |
} elsif ( $cas && $query && $query->param('ticket') ) { |
| 1779 |
$debug and print STDERR "## checkpw - checking CAS\n"; |
1786 |
$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 |
1791 |
my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query, $type ); # EXTERNAL AUTH |
| 1785 |
if ( $retval ) { |
1792 |
if ( $retval ) { |
| 1786 |
@return = ( $retval, $retcard, $retuserid ); |
1793 |
@return = ( $retval, $retcard, $retuserid ); |
| 1787 |
} else { |
|
|
| 1788 |
@return = (0); |
| 1789 |
} |
1794 |
} |
|
|
1795 |
$passwd_ok = $retval; |
| 1790 |
} |
1796 |
} |
| 1791 |
|
1797 |
|
| 1792 |
# If we are in a shibboleth session (shibboleth is enabled, and a shibboleth match attribute is present) |
1798 |
# 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 |
1811 |
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH |
| 1806 |
if ( $retval ) { |
1812 |
if ( $retval ) { |
| 1807 |
@return = ( $retval, $retcard, $retuserid ); |
1813 |
@return = ( $retval, $retcard, $retuserid ); |
| 1808 |
} else { |
|
|
| 1809 |
@return = (0); |
| 1810 |
} |
1814 |
} |
|
|
1815 |
$passwd_ok = $retval; |
| 1811 |
} |
1816 |
} |
|
|
1817 |
} else { |
| 1818 |
$check_internal_as_fallback = 1; |
| 1812 |
} |
1819 |
} |
| 1813 |
|
1820 |
|
| 1814 |
# INTERNAL AUTH |
1821 |
# INTERNAL AUTH |
| 1815 |
@return = checkpw_internal( $dbh, $userid, $password, $no_set_userenv) unless @return; |
1822 |
if ( $check_internal_as_fallback ) { |
|
|
1823 |
@return = checkpw_internal( $dbh, $userid, $password, $no_set_userenv); |
| 1824 |
$passwd_ok = 1 if $return[0] > 0; # 1 or 2 |
| 1825 |
} |
| 1816 |
|
1826 |
|
| 1817 |
if ( $return[0] == 0 ) { |
1827 |
unless ( $passwd_ok ) { # Auth failed |
| 1818 |
$patron->update({ login_attempts => $patron->login_attempts + 1 }) if $patron; |
1828 |
$patron->update({ login_attempts => $patron->login_attempts + 1 }) if $patron; |
| 1819 |
} elsif ( $return[0] == 1 ) { |
1829 |
} elsif ( $patron ) { |
| 1820 |
if ( $patron ) { |
1830 |
# 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 |
1831 |
$patron->update({ login_attempts => 0 }); |
| 1822 |
$patron->update({ login_attempts => 0 }); |
1832 |
$patron->store; |
| 1823 |
$patron->store; |
|
|
| 1824 |
} |
| 1825 |
} |
1833 |
} |
| 1826 |
return @return; |
1834 |
return @return; |
| 1827 |
} |
1835 |
} |
| 1828 |
- |
|
|