added option to open-ils.auth.session.retrieve to return the full cached object,...
authorBill Erickson <erickson@esilibrary.com>
Mon, 14 Feb 2011 17:36:25 +0000 (12:36 -0500)
committerBill Erickson <erickson@esilibrary.com>
Mon, 14 Feb 2011 17:36:25 +0000 (12:36 -0500)
Open-ILS/src/c-apps/oils_auth.c

index eb20fb7..4e7b20b 100644 (file)
@@ -807,8 +807,17 @@ int oilsAuthResetTimeout( osrfMethodContext* ctx ) {
 
 int oilsAuthSessionRetrieve( osrfMethodContext* ctx ) {
        OSRF_METHOD_VERIFY_CONTEXT(ctx);
+    bool returnFull = false;
 
        const char* authToken = jsonObjectGetString( jsonObjectGetIndex(ctx->params, 0));
+
+    if(ctx->params->size > 1) {
+        // caller wants full cached object, with authtime, etc.
+        const char* rt = jsonObjectGetString(jsonObjectGetIndex(ctx->params, 1));
+        if(rt && strcmp(rt, "0") != 0) 
+            returnFull = true;
+    }
+
        jsonObject* cacheObj = NULL;
        oilsEvent* evt = NULL;
 
@@ -828,7 +837,10 @@ int oilsAuthSessionRetrieve( osrfMethodContext* ctx ) {
                        cacheObj = osrfCacheGetObject( key );
                        if(cacheObj) {
                                // Return a copy of the cached user object
-                               osrfAppRespondComplete( ctx, jsonObjectGetKeyConst( cacheObj, "userobj"));
+                if(returnFull)
+                                   osrfAppRespondComplete( ctx, cacheObj);
+                else
+                                   osrfAppRespondComplete( ctx, jsonObjectGetKeyConst( cacheObj, "userobj"));
                                jsonObjectFree(cacheObj);
                        } else {
                                // Auth token is invalid or expired