From d3c925f4561cadc3b7cb26b6cdce850d115e492f Mon Sep 17 00:00:00 2001
From: scottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 23 Mar 2010 13:47:06 +0000
Subject: [PATCH] Tweak to reflect a better understanding of
 oilsUtilsQuickReq(). If the latter calls a method that returns no result, it
 returns a JSON_NULL, not a NULL.

(The previous version worked correctly, but kinda sorta by accident.)

M    Open-ILS/src/c-apps/oils_auth.c


git-svn-id: svn://svn.open-ils.org/ILS/trunk@15936 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/c-apps/oils_auth.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/c-apps/oils_auth.c b/Open-ILS/src/c-apps/oils_auth.c
index bc5a4407d4..27b6455275 100644
--- a/Open-ILS/src/c-apps/oils_auth.c
+++ b/Open-ILS/src/c-apps/oils_auth.c
@@ -461,7 +461,7 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
 			"open-ils.cstore", "open-ils.cstore.direct.actor.card.search", params );
 		jsonObjectFree( params );
 
-		if( card ) {
+		if( card && card->type != JSON_NULL ) {
 			// Determine whether the card is active
 			char* card_active_str = oilsFMGetString( card, "active" );
 			card_active = oilsUtilsIsDBTrue( card_active_str );
@@ -475,6 +475,11 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
 			userObj = oilsUtilsQuickReq(
 					"open-ils.cstore", "open-ils.cstore.direct.actor.user.retrieve", params );
 			jsonObjectFree( params );
+			if( userObj && JSON_NULL == userObj->type ) {
+				// user not found (shouldn't happen, due to foreign key)
+				jsonObjectFree( userObj );
+				userObj = NULL;
+			}
 		}
 	}
 
-- 
2.11.0