From: erickson Date: Mon, 31 Jul 2006 14:43:00 +0000 (+0000) Subject: returning PATRON_CARD_INACTIVE when logging in with an inactive card X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=94e5684713cfa441793237fc8d0d3b3fb72b2f87;p=Evergreen.git returning PATRON_CARD_INACTIVE when logging in with an inactive card git-svn-id: svn://svn.open-ils.org/ILS/trunk@5178 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 705727bed7..a828f8d8ce 100644 --- a/Open-ILS/src/c-apps/oils_auth.c +++ b/Open-ILS/src/c-apps/oils_auth.c @@ -318,6 +318,25 @@ oilsEvent* oilsAuthVerifyWorkstation( +/* see if the card used to login is marked as barred */ +static oilsEvent* oilsAuthCheckCard( osrfMethodContext* ctx, jsonObject* userObj, char* barcode) { + if(!(ctx && userObj && barcode)) return NULL; + osrfLogDebug(OSRF_LOG_MARK, "Checking to see if barcode %s is active", barcode); + + jsonObject* params = jsonParseString("{\"barcode\":\"%s\"}", barcode); + jsonObject* card = oilsUtilsQuickReq( + "open-ils.cstore", "open-ils.cstore.direct.actor.card.search", params ); + + char* active = oilsFMGetString(card, "active"); + if( ! oilsUtilsIsDBTrue(active) ) { + osrfLogInfo(OSRF_LOG_MARK, "barcode %s is not active, returning event", barcode); + return oilsNewEvent(OSRF_LOG_MARK, "PATRON_CARD_INACTIVE"); + } + return NULL; +} + + + int oilsAuthComplete( osrfMethodContext* ctx ) { OSRF_METHOD_VERIFY_CONTEXT(ctx); @@ -360,6 +379,14 @@ int oilsAuthComplete( osrfMethodContext* ctx ) { return 0; } + osrfLogDebug(OSRF_LOG_MARK, "BARCODE = %s", barcode); + if( barcode && (response = oilsAuthCheckCard( ctx, userObj, barcode )) ) { + osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); + oilsEventFree(response); + free(barcode); + return 0; + } + int passOK = -1; if(uname) passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password ); diff --git a/Open-ILS/src/c-apps/oils_utils.c b/Open-ILS/src/c-apps/oils_utils.c index 0e8424b143..4531d36c83 100644 --- a/Open-ILS/src/c-apps/oils_utils.c +++ b/Open-ILS/src/c-apps/oils_utils.c @@ -28,6 +28,12 @@ int oilsFMSetString( jsonObject* object, char* field, char* string ) { } +int oilsUtilsIsDBTrue( char* val ) { + if( val && strcasecmp(val, "f") && strcmp(val, "0") ) return 1; + return 0; +} + + long oilsFMGetObjectId( jsonObject* obj ) { long id = -1; if(!obj) return id; @@ -81,6 +87,10 @@ jsonObject* oilsUtilsStorageReq( char* method, jsonObject* params ) { return oilsUtilsQuickReq( "open-ils.storage", method, params ); } +jsonObject* oilsUtilsCStoreReq( char* method, jsonObject* params ) { + return oilsUtilsQuickReq("open-ils.cstore", method, params); +} + jsonObject* oilsUtilsFetchUserByUsername( char* name ) { diff --git a/Open-ILS/src/c-apps/oils_utils.h b/Open-ILS/src/c-apps/oils_utils.h index 38116860cb..c1ac9a12cd 100644 --- a/Open-ILS/src/c-apps/oils_utils.h +++ b/Open-ILS/src/c-apps/oils_utils.h @@ -61,6 +61,8 @@ jsonObject* oilsUtilsQuickReq( char* service, char* method, jsonObject* params ) jsonObject* oilsUtilsStorageReq( char* method, jsonObject* params ); +jsonObject* oilsUtilsCStoreReq( char* method, jsonObject* params ); + /** * Searches the storage server for a user with the given username * Caller is responsible for freeing the returned object @@ -90,3 +92,6 @@ jsonObject* oilsUtilsFetchWorkstation( long id ); jsonObject* oilsUtilsFetchUserByBarcode(char* barcode); jsonObject* oilsUtilsFetchWorkstationByName( char* name ); + + +int oilsUtilsIsDBTrue( char* val ); diff --git a/Open-ILS/src/extras/ils_events.xml b/Open-ILS/src/extras/ils_events.xml index 8c980cbde4..65d1ec74d6 100644 --- a/Open-ILS/src/extras/ils_events.xml +++ b/Open-ILS/src/extras/ils_events.xml @@ -94,7 +94,7 @@ - + The patron's card is not active diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm index 1389ba838b..64ad8f6b10 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm @@ -217,7 +217,7 @@ sub fetch_user_data { $patron->card($e->retrieve_actor_card($patron->card)); - return OpenILS::Event->new('PATRON_INACTIVE_CARD') + return OpenILS::Event->new('PATRON_CARD_INACTIVE') unless $U->is_true($patron->card->active); $ctx->{requestor} = $ctx->{requestor} || $e->requestor;