use strict;
use warnings;
use Digest::MD5 qw(md5_base64);
+use File::Spec;
use JSON qw/encode_json/;
use URI::Escape;
use CGI::Session;
use C4::Context;
use C4::Templates; # to get the template
use C4::Languages;
-use C4::Branch; # GetBranches
use C4::Search::History;
use Koha;
-use Koha::AuthUtils qw(hash_password);
+use Koha::Caches;
+use Koha::AuthUtils qw(get_script_name hash_password);
+use Koha::Libraries;
+use Koha::LibraryCategories;
+use Koha::Patrons;
use POSIX qw/strftime/;
use List::MoreUtils qw/ any /;
use Encode qw( encode is_utf8);
# use utf8;
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
BEGIN {
sub psgi_env { any { /^psgi\./ } keys %ENV }
if (psgi_env) { die 'psgi:exit' }
else { exit }
}
- $VERSION = 3.07.00.049; # set version for version checking
$debug = $ENV{DEBUG};
@ISA = qw(Exporter);
}
- # If the user logged in is the SCO user and he tries to go out the SCO module, log the user out removing the CGISESSID cookie
+ # If the user logged in is the SCO user and they try to go out of the SCO module, log the user out removing the CGISESSID cookie
if ( $in->{type} eq 'opac' and $in->{template_name} !~ m|sco/| ) {
- if ( C4::Context->preference('AutoSelfCheckID') && $user eq C4::Context->preference('AutoSelfCheckID') ) {
+ if ( $user && C4::Context->preference('AutoSelfCheckID') && $user eq C4::Context->preference('AutoSelfCheckID') ) {
$template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac', $in->{query} );
my $cookie = $in->{query}->cookie(
-name => 'CGISESSID',
-HttpOnly => 1,
);
- $template->param( loginprompt => 1 );
+ $template->param(
+ loginprompt => 1,
+ script_name => get_script_name(),
+ );
print $in->{query}->header(
- -type => 'text/html',
- -charset => 'utf-8',
- -cookie => $cookie,
+ { type => 'text/html',
+ charset => 'utf-8',
+ cookie => $cookie,
+ 'X-Frame-Options' => 'SAMEORIGIN'
+ }
),
$template->output;
safe_exit;
my $borrowernumber;
if ($user) {
- require C4::Members;
# It's possible for $user to be the borrowernumber if they don't have a
# userid defined (and are logging in through some other method, such
# as SSL certs against an email address)
+ my $borrower;
$borrowernumber = getborrowernumber($user) if defined($user);
if ( !defined($borrowernumber) && defined($user) ) {
- my $borrower = C4::Members::GetMember( borrowernumber => $user );
+ $borrower = Koha::Patrons->find( $user );
if ($borrower) {
+ $borrower = $borrower->unblessed;
$borrowernumber = $user;
# A bit of a hack, but I don't know there's a nicer way
# to do it.
$user = $borrower->{firstname} . ' ' . $borrower->{surname};
}
+ } else {
+ $borrower = Koha::Patrons->find( $borrowernumber );
+ $borrower->unblessed if $borrower; # FIXME Otherwise, what to do?
}
# user info
);
}
- my ($borr) = C4::Members::GetMemberDetails($borrowernumber);
- my @bordat;
- $bordat[0] = $borr;
- $template->param( "USER_INFO" => \@bordat );
+ $template->param( "USER_INFO" => $borrower );
my $all_perms = get_all_subpermissions();
my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
- editcatalogue updatecharges management tools editauthorities serials reports acquisition);
+ editcatalogue updatecharges management tools editauthorities serials reports acquisition clubs);
# We are going to use the $flags returned by checkauth
# to create the template's parameters that will indicate
$template->param( CAN_user_staffaccess => 1 );
$template->param( CAN_user_plugins => 1 );
$template->param( CAN_user_coursereserves => 1 );
- foreach my $module ( keys %$all_perms ) {
+ $template->param( CAN_user_clubs => 1 );
+ foreach my $module ( keys %$all_perms ) {
foreach my $subperm ( keys %{ $all_perms->{$module} } ) {
$template->param( "CAN_user_${module}_${subperm}" => 1 );
}
# We show the link in opac
$template->param( EnableOpacSearchHistory => 1 );
}
+ if (C4::Context->preference('LoadSearchHistoryToTheFirstLoggedUser'))
+ {
+ # And if there are searches performed when the user was not logged in,
+ # we add them to the logged-in search history
+ my @recentSearches = C4::Search::History::get_from_session( { cgi => $in->{'query'} } );
+ if (@recentSearches) {
+ my $dbh = C4::Context->dbh;
+ my $query = q{
+ INSERT INTO search_history(userid, sessionid, query_desc, query_cgi, type, total, time )
+ VALUES (?, ?, ?, ?, ?, ?, ?)
+ };
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $borrowernumber,
+ $in->{query}->cookie("CGISESSID"),
+ $_->{query_desc},
+ $_->{query_cgi},
+ $_->{type} || 'biblio',
+ $_->{total},
+ $_->{time},
+ ) foreach @recentSearches;
+
+ # clear out the search history from the session now that
+ # we've saved it to the database
+ }
+ }
+ C4::Search::History::set_to_session( { cgi => $in->{'query'}, search_history => [] } );
- # And if there are searches performed when the user was not logged in,
- # we add them to the logged-in search history
- my @recentSearches = C4::Search::History::get_from_session( { cgi => $in->{'query'} } );
- if (@recentSearches) {
- my $dbh = C4::Context->dbh;
- my $query = q{
- INSERT INTO search_history(userid, sessionid, query_desc, query_cgi, type, total, time )
- VALUES (?, ?, ?, ?, ?, ?, ?)
- };
-
- my $sth = $dbh->prepare($query);
- $sth->execute( $borrowernumber,
- $in->{query}->cookie("CGISESSID"),
- $_->{query_desc},
- $_->{query_cgi},
- $_->{type} || 'biblio',
- $_->{total},
- $_->{time},
- ) foreach @recentSearches;
-
- # clear out the search history from the session now that
- # we've saved it to the database
- C4::Search::History::set_to_session( { cgi => $in->{'query'}, search_history => [] } );
- }
} elsif ( $in->{type} eq 'intranet' and C4::Context->preference('EnableSearchHistory') ) {
$template->param( EnableSearchHistory => 1 );
}
$template->param( dateformat => C4::Context->preference('dateformat') );
}
- $template->param(auth_forwarded_hash => $in->{'query'}->param('auth_forwarded_hash'));
+ $template->param(auth_forwarded_hash => scalar $in->{'query'}->param('auth_forwarded_hash'));
# these template parameters are set the same regardless of $in->{'type'}
LoginFirstname => ( C4::Context->userenv ? C4::Context->userenv->{"firstname"} : "Bel" ),
LoginSurname => C4::Context->userenv ? C4::Context->userenv->{"surname"} : "Inconnu",
emailaddress => C4::Context->userenv ? C4::Context->userenv->{"emailaddress"} : undef,
- loggedinpersona => C4::Context->userenv ? C4::Context->userenv->{"persona"} : undef,
TagsEnabled => C4::Context->preference("TagsEnabled"),
hide_marc => C4::Context->preference("hide_marc"),
item_level_itypes => C4::Context->preference('item-level_itypes'),
patronimages => C4::Context->preference("patronimages"),
- singleBranchMode => C4::Context->preference("singleBranchMode"),
+ singleBranchMode => ( Koha::Libraries->search->count == 1 ),
XSLTDetailsDisplay => C4::Context->preference("XSLTDetailsDisplay"),
XSLTResultsDisplay => C4::Context->preference("XSLTResultsDisplay"),
using_https => $using_https,
noItemTypeImages => C4::Context->preference("noItemTypeImages"),
marcflavour => C4::Context->preference("marcflavour"),
- persona => C4::Context->preference("persona"),
OPACBaseURL => C4::Context->preference('OPACBaseURL'),
);
if ( $in->{'type'} eq "intranet" ) {
$opac_name = C4::Context->userenv->{'branch'};
}
+ my $library_categories = Koha::LibraryCategories->search({categorytype => 'searchdomain', show_in_pulldown => 1}, { order_by => ['categorytype', 'categorycode']});
$template->param(
OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"),
AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"),
- AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"),
- BranchesLoop => GetBranchesLoop($opac_name),
- BranchCategoriesLoop => GetBranchCategories( 'searchdomain', 1, $opac_name ),
+ BranchCategoriesLoop => $library_categories,
+ opac_name => $opac_name,
LibraryName => "" . C4::Context->preference("LibraryName"),
LibraryNameTitle => "" . $LibraryNameTitle,
LoginBranchname => C4::Context->userenv ? C4::Context->userenv->{"branchname"} : "",
opacreadinghistory => C4::Context->preference("opacreadinghistory"),
OPACUserJS => C4::Context->preference("OPACUserJS"),
opacuserlogin => "" . C4::Context->preference("opacuserlogin"),
+ OpenLibrarySearch => C4::Context->preference("OpenLibrarySearch"),
ShowReviewer => C4::Context->preference("ShowReviewer"),
ShowReviewerPhoto => C4::Context->preference("ShowReviewerPhoto"),
suggestion => "" . C4::Context->preference("suggestion"),
my $authnotrequired = shift;
my $flagsrequired = shift;
my $type = shift;
- my $persona = shift;
+ my $emailaddress = shift;
$type = 'opac' unless $type;
my $dbh = C4::Context->dbh;
);
$loggedin = 1;
}
- elsif ($persona) {
-
- # we don't want to set a session because we are being called by a persona callback
+ elsif ( $emailaddress) {
+ # the Google OpenID Connect passes an email address
}
elsif ( $sessionID = $query->cookie("CGISESSID") )
{ # assignment, not comparison
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter'),
- $session->param('persona'), $session->param('shibboleth')
+ $session->param('shibboleth')
);
C4::Context::set_shelves_userenv( 'bar', $session->param('barshelves') );
C4::Context::set_shelves_userenv( 'pub', $session->param('pubshelves') );
$sessiontype = $session->param('sessiontype') || '';
}
if ( ( $query->param('koha_login_context') && ( $q_userid ne $s_userid ) )
- || ( $cas && $query->param('ticket') && !C4::Context->userenv->{'id'} ) || ( $shib && $shib_login && !$logout ) ) {
+ || ( $cas && $query->param('ticket') && !C4::Context->userenv->{'id'} )
+ || ( $shib && $shib_login && !$logout && !C4::Context->userenv->{'id'} )
+ ) {
#if a user enters an id ne to the id in the current session, we need to log them in...
#first we need to clear the anonymous session...
-value => $session->id,
-HttpOnly => 1
);
- $userid = $q_userid;
my $pki_field = C4::Context->preference('AllowPKIAuth');
if ( !defined($pki_field) ) {
print STDERR "ERROR: Missing system preference AllowPKIAuth.\n";
$pki_field = 'None';
}
if ( ( $cas && $query->param('ticket') )
- || $userid
+ || $q_userid
|| ( $shib && $shib_login )
|| $pki_field ne 'None'
- || $persona )
+ || $emailaddress )
{
my $password = $query->param('password');
my $shibSuccess = 0;
my $retuserid;
# Do not pass password here, else shib will not be checked in checkpw.
- ( $return, $cardnumber, $retuserid ) = checkpw( $dbh, $userid, undef, $query );
+ ( $return, $cardnumber, $retuserid ) = checkpw( $dbh, $q_userid, undef, $query );
$userid = $retuserid;
$shibSuccess = $return;
$info{'invalidShibLogin'} = 1 unless ($return);
$info{'invalidCasLogin'} = 1 unless ($return);
}
- elsif ($persona) {
- my $value = $persona;
+ elsif ( $emailaddress ) {
+ my $value = $emailaddress;
# If we're looking up the email, there's a chance that the person
# doesn't have a userid. So if there is none, we pass along the
# borrower number, and the bits of code that need to know the user
# ID will have to be smart enough to handle that.
- require C4::Members;
- my @users_info = C4::Members::GetBorrowersWithEmail($value);
- if (@users_info) {
+ my $patrons = Koha::Patrons->search({ email => $value });
+ if ($patrons->count) {
# First the userid, then the borrowernum
- $value = $users_info[0][1] || $users_info[0][0];
- }
- else {
+ my $patron = $patrons->next;
+ $value = $patron->userid || $patron->borrowernumber;
+ } else {
undef $value;
}
$return = $value ? 1 : 0;
# doesn't have a userid. So if there is none, we pass along the
# borrower number, and the bits of code that need to know the user
# ID will have to be smart enough to handle that.
- require C4::Members;
- my @users_info = C4::Members::GetBorrowersWithEmail($value);
- if (@users_info) {
+ my $patrons = Koha::Patrons->search({ email => $value });
+ if ($patrons->count) {
# First the userid, then the borrowernum
- $value = $users_info[0][1] || $users_info[0][0];
+ my $patron = $patrons->next;
+ $value = $patron->userid || $patron->borrowernumber;
} else {
undef $value;
}
else {
my $retuserid;
( $return, $cardnumber, $retuserid ) =
- checkpw( $dbh, $userid, $password, $query, $type );
+ checkpw( $dbh, $q_userid, $password, $query, $type );
$userid = $retuserid if ($retuserid);
$info{'invalid_username_or_password'} = 1 unless ($return);
}
# $return: 1 = valid user, 2 = superlibrarian
if ($return) {
+ # If DB user is logged in
+ $userid ||= $q_userid if $return == 2;
#_session_log(sprintf "%20s from %16s logged in at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},(strftime '%c', localtime));
if ( $flags = haspermission( $userid, $flagsrequired ) ) {
# if they specify at login, use that
if ( $query->param('branch') ) {
$branchcode = $query->param('branch');
- $branchname = GetBranchName($branchcode);
+ my $library = Koha::Libraries->find($branchcode);
+ $branchname = $library? $library->branchname: '';
}
- my $branches = GetBranches();
- if ( C4::Context->boolean_preference('IndependentBranches') && C4::Context->boolean_preference('Autolocation') ) {
+ my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
+ if ( $type ne 'opac' and C4::Context->boolean_preference('AutoLocation') ) {
# we have to check they are coming from the right ip range
my $domain = $branches->{$branchcode}->{'branchip'};
+ $domain =~ s|\.\*||g;
if ( $ip !~ /^$domain/ ) {
$loggedin = 0;
+ $cookie = $query->cookie(
+ -name => 'CGISESSID',
+ -value => '',
+ -HttpOnly => 1
+ );
$info{'wrongip'} = 1;
}
}
- my @branchesloop;
foreach my $br ( keys %$branches ) {
# now we work with the treatment of ip
$session->param( 'ip', $session->remote_addr() );
$session->param( 'lasttime', time() );
}
- if ($persona) {
- $session->param( 'persona', 1 );
- }
C4::Context->set_userenv(
$session->param('number'), $session->param('id'),
$session->param('cardnumber'), $session->param('firstname'),
$session->param('surname'), $session->param('branch'),
$session->param('branchname'), $session->param('flags'),
$session->param('emailaddress'), $session->param('branchprinter'),
- $session->param('persona'), $session->param('shibboleth')
+ $session->param('shibboleth')
);
}
$session->param( 'ip', $session->remote_addr() );
$session->param( 'sessiontype', 'anon' );
}
- } # END if ( $userid = $query->param('userid') )
+ } # END if ( $q_userid
elsif ( $type eq "opac" ) {
# if we are here this is an anonymous session; add public lists to it and a few other items...
-HttpOnly => 1
);
}
+
+ if ( $userid ) {
+ # track_login also depends on pref TrackLastPatronActivity
+ my $patron = Koha::Patrons->find({ userid => $userid });
+ $patron->track_login if $patron;
+ }
+
return ( $userid, $cookie, $sessionID, $flags );
}
push @inputs, { name => $name, value => $value };
}
+ my $patron = Koha::Patrons->find({ userid => $q_userid }); # Not necessary logged in!
+
my $LibraryNameTitle = C4::Context->preference("LibraryName");
$LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
$LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tt' : 'auth.tt';
my $template = C4::Templates::gettemplate( $template_name, $type, $query );
$template->param(
- branchloop => GetBranchesLoop(),
OpacAdditionalStylesheet => C4::Context->preference("OpacAdditionalStylesheet"),
opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
login => 1,
INPUTS => \@inputs,
+ script_name => get_script_name(),
casAuthentication => C4::Context->preference("casAuthentication"),
shibbolethAuthentication => $shib,
SessionRestrictionByIP => C4::Context->preference("SessionRestrictionByIP"),
wrongip => $info{'wrongip'},
PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"),
PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
- persona => C4::Context->preference("Persona"),
opac_css_override => $ENV{'OPAC_CSS_OVERRIDE'},
+ too_many_login_attempts => ( $patron and $patron->account_locked ),
);
+ $template->param( SCO_login => 1 ) if ( $query->param('sco_user_login') );
$template->param( OpacPublic => C4::Context->preference("OpacPublic") );
$template->param( loginprompt => 1 ) unless $info{'nopermission'};
);
}
+ if (C4::Context->preference('GoogleOpenIDConnect')) {
+ if ($query->param("OpenIDConnectFailed")) {
+ my $reason = $query->param('OpenIDConnectFailed');
+ $template->param(invalidGoogleOpenIDConnectLogin => $reason);
+ }
+ }
+
$template->param(
LibraryName => C4::Context->preference("LibraryName"),
);
# $cookie = $query->cookie(CGISESSID => $session->id
# );
print $query->header(
- -type => 'text/html',
- -charset => 'utf-8',
- -cookie => $cookie
+ { type => 'text/html',
+ charset => 'utf-8',
+ cookie => $cookie,
+ 'X-Frame-Options' => 'SAMEORIGIN'
+ }
),
$template->output;
safe_exit;
# if they specify at login, use that
if ( $query->param('branch') ) {
$branchcode = $query->param('branch');
- $branchname = GetBranchName($branchcode);
+ my $library = Koha::Libraries->find($branchcode);
+ $branchname = $library? $library->branchname: '';
}
- my $branches = GetBranches();
- my @branchesloop;
+ my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search };
foreach my $br ( keys %$branches ) {
# now we work with the treatment of ip
sub check_cookie_auth {
my $cookie = shift;
my $flagsrequired = shift;
+ my $params = shift;
+ my $remote_addr = $params->{remote_addr} || $ENV{REMOTE_ADDR};
my $dbh = C4::Context->dbh;
my $timeout = _timeout_syspref();
$userid = undef;
$sessionID = undef;
return ("expired", undef);
- } elsif ( C4::Context->preference('SessionRestrictionByIP') && $ip ne $ENV{'REMOTE_ADDR'} ) {
+ } elsif ( C4::Context->preference('SessionRestrictionByIP') && $ip ne $remote_addr ) {
# IP address changed
$session->delete();
elsif ( $storage_method eq 'Pg' ) {
$session = new CGI::Session( "driver:PostgreSQL;serializer:yaml;id:md5", $sessionID, { Handle => $dbh } );
}
- elsif ( $storage_method eq 'memcached' && C4::Context->ismemcached ) {
- $session = new CGI::Session( "driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => C4::Context->memcached } );
+ elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) {
+ my $memcached = Koha::Caches->get_instance()->memcached_cache;
+ $session = new CGI::Session( "driver:memcached;serializer:yaml;id:md5", $sessionID, { Memcached => $memcached } );
}
else {
# catch all defaults to tmp should work on all systems
- $session = new CGI::Session( "driver:File;serializer:yaml;id:md5", $sessionID, { Directory => '/tmp' } );
+ my $dir = File::Spec->tmpdir;
+ my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
+ $session = new CGI::Session( "driver:File;serializer:yaml;id:md5", $sessionID, { Directory => "$dir/cgisess_$instance" } );
}
return $session;
}
+
+# FIXME no_set_userenv may be replaced with force_branchcode_for_userenv
+# (or something similar)
+# Currently it's only passed from C4::SIP::ILS::Patron::check_password, but
+# not having a userenv defined could cause a crash.
sub checkpw {
- my ( $dbh, $userid, $password, $query, $type ) = @_;
+ my ( $dbh, $userid, $password, $query, $type, $no_set_userenv ) = @_;
$type = 'opac' unless $type;
- if ($ldap) {
+
+ my @return;
+ my $patron = Koha::Patrons->find({ userid => $userid });
+ my $check_internal_as_fallback = 0;
+ my $passwd_ok = 0;
+ # Note: checkpw_* routines returns:
+ # 1 if auth is ok
+ # 0 if auth is nok
+ # -1 if user bind failed (LDAP only)
+ # 2 if DB user is used (internal only)
+
+ if ( $patron and $patron->account_locked ) {
+ # Nothing to check, account is locked
+ } elsif ($ldap) {
$debug and print STDERR "## checkpw - checking LDAP\n";
my ( $retval, $retcard, $retuserid ) = checkpw_ldap(@_); # EXTERNAL AUTH
- return 0 if $retval == -1; # Incorrect password for LDAP login attempt
- ($retval) and return ( $retval, $retcard, $retuserid );
- }
+ if ( $retval == 1 ) {
+ @return = ( $retval, $retcard, $retuserid );
+ $passwd_ok = 1;
+ }
+ $check_internal_as_fallback = 1 if $retval == 0;
- if ( $cas && $query && $query->param('ticket') ) {
+ } elsif ( $cas && $query && $query->param('ticket') ) {
$debug and print STDERR "## checkpw - checking CAS\n";
# In case of a CAS authentication, we use the ticket instead of the password
my $ticket = $query->param('ticket');
$query->delete('ticket'); # remove ticket to come back to original URL
my ( $retval, $retcard, $retuserid ) = checkpw_cas( $dbh, $ticket, $query, $type ); # EXTERNAL AUTH
- ($retval) and return ( $retval, $retcard, $retuserid );
- return 0;
+ if ( $retval ) {
+ @return = ( $retval, $retcard, $retuserid );
+ }
+ $passwd_ok = $retval;
}
# If we are in a shibboleth session (shibboleth is enabled, and a shibboleth match attribute is present)
# Check for password to asertain whether we want to be testing against shibboleth or another method this
# time around.
- if ( $shib && $shib_login && !$password ) {
+ elsif ( $shib && $shib_login && !$password ) {
$debug and print STDERR "## checkpw - checking Shibboleth\n";
# Then, we check if it matches a valid koha user
if ($shib_login) {
my ( $retval, $retcard, $retuserid ) = C4::Auth_with_shibboleth::checkpw_shib($shib_login); # EXTERNAL AUTH
- ($retval) and return ( $retval, $retcard, $retuserid );
- return 0;
+ if ( $retval ) {
+ @return = ( $retval, $retcard, $retuserid );
+ }
+ $passwd_ok = $retval;
}
+ } else {
+ $check_internal_as_fallback = 1;
}
# INTERNAL AUTH
- return checkpw_internal(@_)
+ if ( $check_internal_as_fallback ) {
+ @return = checkpw_internal( $dbh, $userid, $password, $no_set_userenv);
+ $passwd_ok = 1 if $return[0] > 0; # 1 or 2
+ }
+
+ if( $patron ) {
+ if ( $passwd_ok ) {
+ $patron->update({ login_attempts => 0 });
+ } else {
+ $patron->update({ login_attempts => $patron->login_attempts + 1 });
+ }
+ }
+ return @return;
}
sub checkpw_internal {
- my ( $dbh, $userid, $password ) = @_;
+ my ( $dbh, $userid, $password, $no_set_userenv ) = @_;
$password = Encode::encode( 'UTF-8', $password )
if Encode::is_utf8($password);
if ( checkpw_hash( $password, $stored_hash ) ) {
C4::Context->set_userenv( "$borrowernumber", $userid, $cardnumber,
- $firstname, $surname, $branchcode, $branchname, $flags );
+ $firstname, $surname, $branchcode, $branchname, $flags ) unless $no_set_userenv;
return 1, $cardnumber, $userid;
}
}
if ( checkpw_hash( $password, $stored_hash ) ) {
C4::Context->set_userenv( $borrowernumber, $userid, $cardnumber,
- $firstname, $surname, $branchcode, $branchname, $flags );
+ $firstname, $surname, $branchcode, $branchname, $flags ) unless $no_set_userenv;
return 1, $cardnumber, $userid;
}
}