returning PATRON_CARD_INACTIVE when logging in with an inactive card
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Jul 2006 14:43:00 +0000 (14:43 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Jul 2006 14:43:00 +0000 (14:43 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5178 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_auth.c
Open-ILS/src/c-apps/oils_utils.c
Open-ILS/src/c-apps/oils_utils.h
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/OpenILS/Application/Circ/ScriptBuilder.pm

index 705727b..a828f8d 100644 (file)
@@ -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 );
index 0e8424b..4531d36 100644 (file)
@@ -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 ) {
index 3811686..c1ac9a1 100644 (file)
@@ -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 );
index 8c980cb..65d1ec7 100644 (file)
@@ -94,7 +94,7 @@
                </desc>
        </event>
 
-       <event code='1216' textcode='PATRON_INACTIVE_CARD'>
+       <event code='1216' textcode='PATRON_CARD_INACTIVE'>
                <desc xml:lang="en-US">The patron's card is not active</desc>
        </event>
 
index 1389ba8..64ad8f6 100644 (file)
@@ -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;