returning event on login when the user is marked inactive
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Jul 2006 16:14:54 +0000 (16:14 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 31 Jul 2006 16:14:54 +0000 (16:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5184 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/c-apps/oils_auth.c
Open-ILS/src/extras/ils_events.xml
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/skin/default/xml/common/login.xml

index a828f8d..b272ff8 100644 (file)
@@ -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 ) {
index 65d1ec7..4d29950 100644 (file)
@@ -97,6 +97,9 @@
        <event code='1216' textcode='PATRON_CARD_INACTIVE'>
                <desc xml:lang="en-US">The patron's card is not active</desc>
        </event>
+       <event code='1217' textcode='PATRON_INACTIVE'>
+               <desc xml:lang="en-US">This account is marked as inactive</desc>
+       </event>
 
 
 
index 55a388c..8f28e5c 100644 (file)
@@ -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;
index 1a62889..6f7b1f0 100644 (file)
                The barcode used to login is marked as inactive.  Please contact your local library.
        </span>
 
+       <span id='patron_inactive_alert' class='hide_me'>
+               This account has been deactivated.  Please contact your local library.
+       </span>
+
        <span id='patron_login_failed' class='hide_me'>
                Login failed.  The username or password provided was not valid.  
                Make sure Caps-Lock is off and try again or contact your local library.