Bugzilla – Attachment 61886 Details for
Bug 16892
Add automatic patron registration via OAuth2 login
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16892: Add automatic patron registration via OAuth2 login
Bug-16892-Add-automatic-patron-registration-via-OA.patch (text/plain), 5.38 KB, created by
Biblibre Sandboxes
on 2017-04-05 14:00:08 UTC
(
hide
)
Description:
Bug 16892: Add automatic patron registration via OAuth2 login
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2017-04-05 14:00:08 UTC
Size:
5.38 KB
patch
obsolete
>From 1c61e38fa5362300d1bee5844edec2cc7ae4e1d3 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Mon, 11 Jul 2016 00:42:40 -0400 >Subject: [PATCH] Bug 16892: Add automatic patron registration via OAuth2 login > >10988 added the ability to log into the OPAC authenticating with >Google Open ID Connect. This extends it, by allowing an >unregistered patron to have an account automatically created >with default category code and branch. > >This is accomplished by adding 3 system preferences. >- GoogleOpenIDConnectAutoRegister > whether it will attempt to auto-register the patron. >- GoogleOpenIDConnectDefaultCategory > This category code will be used to create Google OpenID Connect patrons. >- GoogleOpenIDConnectDefaultBranch' > This branch code will be used to create Google OpenID Connect patrons. > >Sponsored-by: Tulong Aklatan > >Signed-off-by: Eugene Jose Espinoza <eugenegf@yahoo.com> >--- > .../bug_16892_AutomaticPatronSystemPreferences.sql | 4 ++++ > .../prog/en/modules/admin/preferences/admin.pref | 12 +++++++++++ > opac/svc/auth/googleopenidconnect | 25 ++++++++++++++++++++++ > 3 files changed, 41 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_16892_AutomaticPatronSystemPreferences.sql > >diff --git a/installer/data/mysql/atomicupdate/bug_16892_AutomaticPatronSystemPreferences.sql b/installer/data/mysql/atomicupdate/bug_16892_AutomaticPatronSystemPreferences.sql >new file mode 100644 >index 0000000..229a8c9 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_16892_AutomaticPatronSystemPreferences.sql >@@ -0,0 +1,4 @@ >+INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+('GoogleOpenIDConnectAutoRegister', '0',NULL,' Google OpenID Connect logins to auto-register patrons.','YesNo'), >+('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'), >+('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index ba49128..b9853e5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -156,6 +156,18 @@ Administration: > - "Google OpenID Connect Restrict to domain (or subdomain of this domain): " > - pref: GoogleOpenIDConnectDomain > - Leave blank for all google domains >+ - >+ - pref: GoogleOpenIDConnectAutoRegister >+ choices: >+ yes: Allow >+ no: "Don't Allow" >+ - users logging in with Google Open ID to automatically register. >+ - >+ - pref: GoogleOpenIDConnectDefaultCategory >+ - Use this category code when automatically registering a Google Open ID patron. >+ - >+ - pref: GoogleOpenIDConnectDefaultBranch >+ - Use this branch code when automatically registering a Google Open ID patron. > Share anonymous usage statistics: > - > - "Share anonymous Koha usage data with the Koha community: " >diff --git a/opac/svc/auth/googleopenidconnect b/opac/svc/auth/googleopenidconnect >index ab71918..eae7b34 100755 >--- a/opac/svc/auth/googleopenidconnect >+++ b/opac/svc/auth/googleopenidconnect >@@ -34,7 +34,9 @@ use Modern::Perl; > use CGI qw ( -utf8 escape ); > use C4::Auth qw{ checkauth get_session get_template_and_user }; > use C4::Context; >+use C4::Members; > use C4::Output; >+use Koha::Patrons; > > use LWP::UserAgent; > use HTTP::Request::Common qw{ POST }; >@@ -179,6 +181,29 @@ elsif ( defined $query->param('code') ) { > . ' .' ); > } > else { >+ my $auto_registration = C4::Context->preference('GoogleOpenIDConnectAutoRegister') // q{0}; >+ my $borrower = Koha::Patrons->find( { email => $email } ); >+ if (! $borrower && $auto_registration==1) { >+ my $cardnumber = fixup_cardnumber(); >+ my $firstname = $claims_json->{'given_name'} // q{}; >+ my $surname = $claims_json->{'family_name'} // q{}; >+ my $delimiter = $firstname ? q{.} : q{}; >+ my $userid = $firstname . $delimiter . $surname; >+ my $categorycode = C4::Context->preference('GoogleOpenIDConnectDefaultCategory') // q{}; >+ my $branchcode = C4::Context->preference('GoogleOpenIDConnectDefaultBranch') // q{}; >+ my $password = undef; >+ $borrower = Koha::Patron->new( { >+ cardnumber => $cardnumber, >+ firstname => $firstname, >+ surname => $surname, >+ email => $email, >+ categorycode => $categorycode, >+ branchcode => $branchcode, >+ userid => $userid, >+ password => $password, >+ } ); >+ $borrower->store(); >+ } > my ( $userid, $cookie, $session_id ) = > checkauth( $query, 1, {}, 'opac', $email ); > if ($userid) { # A user with this email is registered in koha >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16892
:
53257
|
53485
|
53488
|
56081
|
57111
|
57112
|
57113
|
58373
|
58374
|
58375
|
61800
|
61801
|
61802
|
61803
|
61804
|
61886
|
61887
|
61888
|
61889
|
63117
|
63118
|
63119
|
63120
|
65316