Lines 34-40
use Modern::Perl;
Link Here
|
34 |
use CGI qw ( -utf8 escape ); |
34 |
use CGI qw ( -utf8 escape ); |
35 |
use C4::Auth qw{ checkauth get_session get_template_and_user }; |
35 |
use C4::Auth qw{ checkauth get_session get_template_and_user }; |
36 |
use C4::Context; |
36 |
use C4::Context; |
|
|
37 |
use C4::Members; |
37 |
use C4::Output; |
38 |
use C4::Output; |
|
|
39 |
use Koha::Patrons; |
38 |
|
40 |
|
39 |
use LWP::UserAgent; |
41 |
use LWP::UserAgent; |
40 |
use HTTP::Request::Common qw{ POST }; |
42 |
use HTTP::Request::Common qw{ POST }; |
Lines 179-184
elsif ( defined $query->param('code') ) {
Link Here
|
179 |
. ' .' ); |
181 |
. ' .' ); |
180 |
} |
182 |
} |
181 |
else { |
183 |
else { |
|
|
184 |
my $auto_registration = C4::Context->preference('GoogleOpenIDConnectAutoRegister') // q{0}; |
185 |
my $borrower = Koha::Patrons->find( { email => $email } ); |
186 |
if (! $borrower && $auto_registration==1) { |
187 |
my $cardnumber = fixup_cardnumber(); |
188 |
my $firstname = $claims_json->{'given_name'} // q{}; |
189 |
my $surname = $claims_json->{'family_name'} // q{}; |
190 |
my $delimiter = $firstname ? q{.} : q{}; |
191 |
my $userid = $firstname . $delimiter . $surname; |
192 |
my $categorycode = C4::Context->preference('GoogleOpenIDConnectDefaultCategory') // q{}; |
193 |
my $branchcode = C4::Context->preference('GoogleOpenIDConnectDefaultBranch') // q{}; |
194 |
my $password = undef; |
195 |
$borrower = Koha::Patron->new( { |
196 |
cardnumber => $cardnumber, |
197 |
firstname => $firstname, |
198 |
surname => $surname, |
199 |
email => $email, |
200 |
categorycode => $categorycode, |
201 |
branchcode => $branchcode, |
202 |
userid => $userid, |
203 |
password => $password, |
204 |
} ); |
205 |
$borrower->store(); |
206 |
} |
182 |
my ( $userid, $cookie, $session_id ) = |
207 |
my ( $userid, $cookie, $session_id ) = |
183 |
checkauth( $query, 1, {}, 'opac', $email ); |
208 |
checkauth( $query, 1, {}, 'opac', $email ); |
184 |
if ($userid) { # A user with this email is registered in koha |
209 |
if ($userid) { # A user with this email is registered in koha |
185 |
- |
|
|