From: erickson Date: Mon, 31 Jul 2006 16:14:54 +0000 (+0000) Subject: returning event on login when the user is marked inactive X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=81661b00e2fef89662ae7fbfd1fff894545cdd9b;p=Evergreen.git returning event on login when the user is marked inactive git-svn-id: svn://svn.open-ils.org/ILS/trunk@5184 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_auth.c b/Open-ILS/src/c-apps/oils_auth.c index a828f8d8ce..b272ff87f5 100644 --- a/Open-ILS/src/c-apps/oils_auth.c +++ b/Open-ILS/src/c-apps/oils_auth.c @@ -329,9 +329,12 @@ static oilsEvent* oilsAuthCheckCard( osrfMethodContext* ctx, jsonObject* userObj char* active = oilsFMGetString(card, "active"); if( ! oilsUtilsIsDBTrue(active) ) { + free(active); osrfLogInfo(OSRF_LOG_MARK, "barcode %s is not active, returning event", barcode); return oilsNewEvent(OSRF_LOG_MARK, "PATRON_CARD_INACTIVE"); } + + free(active); return NULL; } @@ -372,14 +375,30 @@ int oilsAuthComplete( osrfMethodContext* ctx ) { return 0; } - /* check to see if the user is allowed to login */ - if( oilsAuthCheckLoginPerm( ctx, userObj, type ) == -1 ) { - jsonObjectFree(userObj); + /* first let's see if they have the right credentials */ + int passOK = -1; + if(uname) passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password ); + else if (barcode) + passOK = oilsAuthVerifyPassword( ctx, userObj, barcode, password ); + + if( passOK < 0 ) { + free(barcode); + return passOK; + } + + /* first see if their account is inactive */ + char* active = oilsFMGetString(userObj, "active"); + if( !oilsUtilsIsDBTrue(active) ) { + response = oilsNewEvent(OSRF_LOG_MARK, "PATRON_INACTIVE"); + osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); + oilsEventFree(response); free(barcode); + free(active); return 0; } + free(active); - osrfLogDebug(OSRF_LOG_MARK, "BARCODE = %s", barcode); + /* then see if the barcode they used is active */ if( barcode && (response = oilsAuthCheckCard( ctx, userObj, barcode )) ) { osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); oilsEventFree(response); @@ -387,16 +406,14 @@ int oilsAuthComplete( osrfMethodContext* ctx ) { return 0; } - - int passOK = -1; - if(uname) passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password ); - else if (barcode) - passOK = oilsAuthVerifyPassword( ctx, userObj, barcode, password ); - if( passOK < 0 ) { + /* check to see if the user is even allowed to login */ + if( oilsAuthCheckLoginPerm( ctx, userObj, type ) == -1 ) { + jsonObjectFree(userObj); free(barcode); - return passOK; + return 0; } + /* if a workstation is defined, flesh the user with the workstation info */ if( workstation != NULL ) { diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 65d1ec74d6..4d29950a3f 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -97,6 +97,9 @@ The patron's card is not active + + This account is marked as inactive + diff --git a/Open-ILS/web/opac/common/js/opac_utils.js b/Open-ILS/web/opac/common/js/opac_utils.js index 55a388c411..8f28e5cb9d 100644 --- a/Open-ILS/web/opac/common/js/opac_utils.js +++ b/Open-ILS/web/opac/common/js/opac_utils.js @@ -593,6 +593,11 @@ function doLogin(suppressEvents) { if( checkILSEvent(auth_result) ) { + if( auth_result.textcode == 'PATRON_INACTIVE' ) { + alertId('patron_inactive_alert'); + return; + } + if( auth_result.textcode == 'PATRON_CARD_INACTIVE' ) { alertId('patron_card_inactive_alert'); return; diff --git a/Open-ILS/web/opac/skin/default/xml/common/login.xml b/Open-ILS/web/opac/skin/default/xml/common/login.xml index 1a628892fb..6f7b1f0fe5 100644 --- a/Open-ILS/web/opac/skin/default/xml/common/login.xml +++ b/Open-ILS/web/opac/skin/default/xml/common/login.xml @@ -104,6 +104,10 @@ The barcode used to login is marked as inactive. Please contact your local library. + + This account has been deactivated. Please contact your local library. + + Login failed. The username or password provided was not valid. Make sure Caps-Lock is off and try again or contact your local library.