From 721925ab0f94c933c0f0794fca7f316395aae42f Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 12 Jun 2018 13:44:41 -0400 Subject: [PATCH] LP#1775466 Port auth_proxy login support Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/core/auth.service.ts | 30 +++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/core/auth.service.ts b/Open-ILS/src/eg2/src/app/core/auth.service.ts index 3176bf80e9..1de67dbbee 100644 --- a/Open-ILS/src/eg2/src/app/core/auth.service.ts +++ b/Open-ILS/src/eg2/src/app/core/auth.service.ts @@ -116,14 +116,40 @@ export class AuthService { }); } - login(args: AuthLoginArgs, isOpChange?: boolean): Promise { - return this.net.request('open-ils.auth', 'open-ils.auth.login', args) + loginApi(args: AuthLoginArgs, service: string, + method: string, isOpChange?: boolean): Promise { + + return this.net.request(service, method, args) .toPromise().then(res => { return this.handleLoginResponse( args, this.egEvt.parse(res), isOpChange); }); } + login(args: AuthLoginArgs, isOpChange?: boolean): Promise { + let service = 'open-ils.auth'; + let method = 'open-ils.auth.login'; + + return this.net.request( + 'open-ils.auth_proxy', + 'open-ils.auth_proxy.enabled') + .toPromise().then( + enabled => { + if (Number(enabled) === 1) { + service = 'open-ils.auth_proxy'; + method = 'open-ils.auth_proxy.login'; + } + return this.loginApi(args, service, method, isOpChange); + }, + error => { + // auth_proxy check resulted in a low-level error. + // Likely the service is not running. Fall back to + // standard auth login. + return this.loginApi(args, service, method, isOpChange); + } + ); + } + handleLoginResponse( args: AuthLoginArgs, evt: EgEvent, isOpChange: boolean): Promise { -- 2.11.0