LP #1255561 Check username beginning with digit for login user/abowling/lp1255561_username_begins_with_digit
authorAdam Bowling <abowling@emeralddata.net>
Wed, 28 Jan 2015 16:35:35 +0000 (11:35 -0500)
committerAdam Bowling <abowling@emeralddata.net>
Wed, 28 Jan 2015 16:35:35 +0000 (11:35 -0500)
Currently, login authentication treats every username entry
that begins with a digit as a barcode. This patch runs through
that iteration, but if authentication fails, then tries a
username entry beginning with a digit as a username, instead of
a barcode, and retries the authentication as such, and returns
success if open-ils.auth matches the digit-beginning username
with the correct password.

Signed-off-by: Adam Bowling <abowling@emeralddata.net>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm

index 856b7de..f799da4 100644 (file)
@@ -432,6 +432,25 @@ sub load_login {
             'open-ils.auth_proxy',
             'open-ils.auth_proxy.login', $args);
     }
+
+    #If login fails, try what script thinks is a barcode as username
+    if($U->event_code($response)) {
+        $args->{username} = $args->{barcode};
+        if (!$auth_proxy_enabled) {
+            my $seed = $U->simplereq(
+                'open-ils.auth',
+                'open-ils.auth.authenticate.init', $username);
+            $args->{password} = md5_hex($seed . md5_hex($password));
+            $response = $U->simplereq(
+                'open-ils.auth', 'open-ils.auth.authenticate.complete', $args);
+        } else {
+            $args->{password} = $password;
+            $response = $U->simplereq(
+                'open-ils.auth_proxy',
+                'open-ils.auth_proxy.login', $args);
+        }
+    }
+
     $self->timelog("Checked password");
 
     if($U->event_code($response)) {