[open-ils-commits] r15362 - branches/rel_1_6/Open-ILS/src/c-apps (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jan 21 16:41:38 EST 2010


Author: erickson
Date: 2010-01-21 16:41:32 -0500 (Thu, 21 Jan 2010)
New Revision: 15362

Modified:
   branches/rel_1_6/Open-ILS/src/c-apps/oils_auth.c
Log:
backporting 13623: fix for login failure reports inactive account

Modified: branches/rel_1_6/Open-ILS/src/c-apps/oils_auth.c
===================================================================
--- branches/rel_1_6/Open-ILS/src/c-apps/oils_auth.c	2010-01-21 18:07:15 UTC (rev 15361)
+++ branches/rel_1_6/Open-ILS/src/c-apps/oils_auth.c	2010-01-21 21:41:32 UTC (rev 15362)
@@ -371,7 +371,7 @@
 	const char* type		= jsonObjectGetString(jsonObjectGetKeyConst(args, "type"));
 	double orgloc			= jsonObjectGetNumber(jsonObjectGetKeyConst(args, "org"));
 	const char* workstation = jsonObjectGetString(jsonObjectGetKeyConst(args, "workstation"));
-	char* barcode			= jsonObjectToSimpleString(jsonObjectGetKeyConst(args, "barcode"));
+	const char* barcode		= jsonObjectGetString(jsonObjectGetKeyConst(args, "barcode"));
 
 	const char* ws = (workstation) ? workstation : "";
 
@@ -379,7 +379,6 @@
 	if(!type) type = OILS_AUTH_STAFF;
 
 	if( !( (uname || barcode) && password) ) {
-		free(barcode);
 		return osrfAppRequestRespondException( ctx->session, ctx->request, 
 			"username/barcode and password required for method: %s", ctx->method->name );
 	}
@@ -392,10 +391,10 @@
 	
 	if(!userObj) { 
 		response = oilsNewEvent( OSRF_LOG_MARK, OILS_EVENT_AUTH_FAILED );
-		osrfLogInfo(OSRF_LOG_MARK,  "failed login: username=%s, barcode=%s, workstation=%s", uname, barcode, ws );
+		osrfLogInfo(OSRF_LOG_MARK,  "failed login: username=%s, barcode=%s, workstation=%s",
+				uname, (barcode ? barcode : "(none)"), ws );
 		osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
 		oilsEventFree(response);
-		free(barcode);
 		return 0;
 	}
 
@@ -407,18 +406,20 @@
 
 	if( passOK < 0 ) {
 		jsonObjectFree(userObj);
-		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");
+		if( passOK )
+			response = oilsNewEvent( OSRF_LOG_MARK, "PATRON_INACTIVE" );
+		else
+			response = oilsNewEvent( OSRF_LOG_MARK, OILS_EVENT_AUTH_FAILED );
+
 		osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
 		oilsEventFree(response);
 		jsonObjectFree(userObj);
-		free(barcode);
 		free(active);
 		return 0;
 	}
@@ -429,7 +430,6 @@
 		osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
 		oilsEventFree(response);
 		jsonObjectFree(userObj);
-		free(barcode);
 		return 0;
 	}
 
@@ -437,7 +437,6 @@
 	/* check to see if the user is even allowed to login */
 	if( oilsAuthCheckLoginPerm( ctx, userObj, type ) == -1 ) {
 		jsonObjectFree(userObj);
-		free(barcode);
 		return 0;
 	}
 	
@@ -450,7 +449,6 @@
 			jsonObjectFree(userObj);
 			osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
 			oilsEventFree(response);
-			free(barcode);
 			return 0;
 		}
 
@@ -471,13 +469,13 @@
 
 	} else {
 		response = oilsNewEvent( OSRF_LOG_MARK, OILS_EVENT_AUTH_FAILED );
-		osrfLogInfo(OSRF_LOG_MARK,  "failed login: username=%s, barcode=%s, workstation=%s", uname, barcode, ws );
+		osrfLogInfo(OSRF_LOG_MARK,  "failed login: username=%s, barcode=%s, workstation=%s",
+				uname, (barcode ? barcode : "(none)"), ws );
 	}
 
 	jsonObjectFree(userObj);
 	osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
 	oilsEventFree(response);
-	free(barcode);
 
 	if(freeable_uname) free(freeable_uname);
 



More information about the open-ils-commits mailing list