From e735eecbb92e03ef1f5c772fd6c65800e8c0a1a2 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 3 Mar 2006 21:01:48 +0000 Subject: [PATCH] auth now takes a workstation id as an optional 5th parameter 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Open-ILS/src/c-apps/oils_auth.c b/Open-ILS/src/c-apps/oils_auth.c index db232df17e..168e68ccd3 100644 --- a/Open-ILS/src/c-apps/oils_auth.c +++ b/Open-ILS/src/c-apps/oils_auth.c @@ -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 ); -- 2.43.2