Bug 9587 : Handling mismatched emails better
authorChris Cormack <chrisc@catalyst.net.nz>
Wed, 20 Feb 2013 22:34:41 +0000 (11:34 +1300)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sun, 24 Feb 2013 15:15:56 +0000 (10:15 -0500)
To test:

Sign in to Koha via persona using an email that doesn't exist in Koha

Before the patch you will get into an infinite redirect loop

After the patch it will give you an error message

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Comment: Work as described. No errors.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc
opac/svc/login

index b875028..78c8bd3 100644 (file)
@@ -72,7 +72,10 @@ navigator.id.watch({
             function (data) {
                 window.location = '/cgi-bin/koha/opac-user.pl';
             }
-        );
+        )
+        .fail(function() { var errstr = _("Could not login, perhaps your Persona email does not match your Koha one");
+            alert(errstr);
+        });
     },
     onlogout: function () {
         window.location = '/cgi-bin/koha/opac-main.pl?logout.x=1';
index 607b566..ed41e08 100755 (executable)
@@ -44,8 +44,14 @@ if ( $response->is_success ) {
     my $decoded_json = decode_json($content);
     my ( $userid, $cookie, $sessionID ) =
       checkauth( $query, 1,  { borrow => 1 }, 'opac', $decoded_json->{'email'} );
-    print $query->header( -cookie => $cookie );
-    print $decoded_json;
+    if ($userid) { # a valid user has logged in
+        print $query->header( -cookie => $cookie );
+        print $decoded_json;
+    }
+    else {
+# logged in with an email that isn't associated with a borrower
+        die "Email not associated with a borrower";
+    }
 }
 else {
     warn $response->status_line, "\n";