View | Details | Raw Unified | Return to bug 16892
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_16892_AutomaticPatronSystemPreferences.sql (+4 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('GoogleOpenIDConnectAutoRegister',   '0',NULL,' Google OpenID Connect logins to auto-register patrons.','YesNo'),
3
('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'),
4
('GoogleOpenIDConnectDefaultBranch',  '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref (+12 lines)
Lines 156-161 Administration: Link Here
156
            - "Google OpenID Connect Restrict to domain (or subdomain of this domain): "
156
            - "Google OpenID Connect Restrict to domain (or subdomain of this domain): "
157
            - pref: GoogleOpenIDConnectDomain
157
            - pref: GoogleOpenIDConnectDomain
158
            - Leave blank for all google domains
158
            - Leave blank for all google domains
159
        -
160
            - pref: GoogleOpenIDConnectAutoRegister
161
              choices:
162
                yes: Allow
163
                no: "Don't Allow"
164
            - users logging in with Google Open ID to automatically register.
165
        -
166
            - pref: GoogleOpenIDConnectDefaultCategory
167
            - Use this category code when automatically registering a Google Open ID patron.
168
        -
169
            - pref: GoogleOpenIDConnectDefaultBranch
170
            - Use this branch code when automatically registering a Google Open ID patron.
159
    Mozilla Persona:
171
    Mozilla Persona:
160
        -
172
        -
161
            - "Allow Mozilla persona for login: "
173
            - "Allow Mozilla persona for login: "
(-)a/opac/svc/auth/googleopenidconnect (-1 / +25 lines)
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
- 

Return to bug 16892