From 19e5d9750d5132cefdd78122fd5b7f8e58d50612 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 12 Jun 2018 12:02:02 -0400 Subject: [PATCH] LP#1755258 Browser client auth proxy login support Check if the auth_proxy service is enabled during login and use the proxy login API when it's available, otherwise fall back to standard Evergreen open-ils.auth login. Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- .../web/js/ui/default/staff/services/auth.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/auth.js b/Open-ILS/web/js/ui/default/staff/services/auth.js index 9048a34b78..c46e37e7a1 100644 --- a/Open-ILS/web/js/ui/default/staff/services/auth.js +++ b/Open-ILS/web/js/ui/default/staff/services/auth.js @@ -169,7 +169,6 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) { } service.login_api(args).then(function(evt) { - if (evt.textcode == 'SUCCESS') { service.handle_login_ok(args, evt); ops.deferred.resolve({ @@ -240,7 +239,13 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) { return service.testAuthToken(); } - service.login_api = function(args) { + service.login_via_auth_proxy = function(args) { + return egNet.request( + 'open-ils.auth_proxy', + 'open-ils.auth_proxy.login', args); + } + + service.login_via_auth = function(args) { return egNet.request( 'open-ils.auth', 'open-ils.auth.authenticate.init', args.username) @@ -257,6 +262,27 @@ function($q , $timeout , $rootScope , $window , $location , egNet , egHatch) { ); } + service.login_api = function(args) { + + return egNet.request( + 'open-ils.auth_proxy', + 'open-ils.auth_proxy.enabled') + .then( + function(enabled) { + console.log('proxy check returned ' + enabled); + if (Number(enabled) === 1) { + return service.login_via_auth_proxy(args); + } else { + return service.login_via_auth(args); + } + }, + function() { + // request failed, likely a result of auth_proxy not running. + return service.login_via_auth(args); + } + ); + } + service.handle_login_ok = function(args, evt) { service.ws = args.workstation; egHatch.setLoginSessionItem('eg.auth.token', evt.payload.authtoken); -- 2.43.2