auth now takes a workstation id as an optional 5th parameter
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 3 Mar 2006 21:01:48 +0000 (21:01 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 3 Mar 2006 21:01:48 +0000 (21:01 +0000)
if available, the ws is retrieved and wsid and ws_ou are
set on the user

git-svn-id: svn://svn.open-ils.org/ILS/trunk@3253 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index db232df..168e68c 100644 (file)
@@ -277,6 +277,18 @@ oilsEvent* oilsAuthHandleLoginOK(
        return response;
 }
 
+oilsEvent* oilsAuthVerifyWorkstation( osrfMethodContext* ctx, jsonObject* userObj, double wsid ) {
+       osrfLogInfo(OSRF_LOG_MARK, "Attaching workstation to user at login: %lf", wsid);
+       jsonObject* workstation = oilsUtilsFetchWorkstation(wsid);
+       if(!workstation) return oilsNewEvent("WORKSTATION_NOT_FOUND");
+       DOUBLE_TO_STRING(wsid);
+       char* orgid = oilsFMGetString(workstation, "owning_lib");
+       oilsFMSetString(userObj, "wsid", DOUBLESTR);
+       oilsFMSetString(userObj, "ws_ou", orgid);
+       free(orgid);
+       return NULL;
+}
+
 
 
 int oilsAuthComplete( osrfMethodContext* ctx ) {
@@ -286,6 +298,7 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
        char* password = jsonObjectGetString(jsonObjectGetIndex(ctx->params, 1));
        char* type              = jsonObjectGetString(jsonObjectGetIndex(ctx->params, 2));
        double orgloc   = jsonObjectGetNumber(jsonObjectGetIndex(ctx->params, 3));
+       double wsid             = jsonObjectGetNumber(jsonObjectGetIndex(ctx->params, 4));
 
        if(!type) type = OILS_AUTH_STAFF;
 
@@ -313,6 +326,13 @@ int oilsAuthComplete( osrfMethodContext* ctx ) {
        int passOK = oilsAuthVerifyPassword( ctx, userObj, uname, password );
        if( passOK < 0 ) return passOK;
 
+       if( wsid > 0 && (response = oilsAuthVerifyWorkstation( ctx, userObj, wsid )) ) {
+               jsonObjectFree(userObj);
+               osrfAppRespondComplete( ctx, oilsEventToJSON(response) ); 
+               oilsEventFree(response);
+               return 0;
+       }
+
        if( passOK ) {
                response = oilsAuthHandleLoginOK( userObj, uname, type, orgloc );