From bc1de44899000f87905f68e5928f74dc5267ce2b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 1 Feb 2016 10:15:23 -0500 Subject: [PATCH] LP#1468422 Always default to root org unit If no org unit is passed by the caller, always default to the root org unit. Signed-off-by: Bill Erickson Signed-off-by: Dan Wells --- Open-ILS/src/c-apps/oils_auth_internal.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/c-apps/oils_auth_internal.c b/Open-ILS/src/c-apps/oils_auth_internal.c index c64a6c0763..c7621b107a 100644 --- a/Open-ILS/src/c-apps/oils_auth_internal.c +++ b/Open-ILS/src/c-apps/oils_auth_internal.c @@ -278,15 +278,19 @@ int oilsAutInternalCreateSession(osrfMethodContext* ctx) { const jsonObject* args = jsonObjectGetIndex(ctx->params, 0); const char* user_id = jsonObjectGetString(jsonObjectGetKeyConst(args, "user_id")); - const char* org_unit = jsonObjectGetString(jsonObjectGetKeyConst(args, "org_unit")); const char* login_type = jsonObjectGetString(jsonObjectGetKeyConst(args, "login_type")); const char* workstation = jsonObjectGetString(jsonObjectGetKeyConst(args, "workstation")); + int org_unit = jsonObjectGetNumber(jsonObjectGetKeyConst(args, "org_unit")); - if ( !(user_id && login_type && org_unit) ) { + if ( !(user_id && login_type) ) { return osrfAppRequestRespondException( ctx->session, ctx->request, "Missing parameters for method: %s", ctx->method->name ); } + // default to the root org unit if none is provided. + if (org_unit < 1) + org_unit = oilsUtilsGetRootOrgId(); + oilsEvent* response = NULL; // fetch the user object @@ -318,7 +322,7 @@ int oilsAutInternalCreateSession(osrfMethodContext* ctx) { } // determine the auth/cache timeout - long timeout = oilsAuthGetTimeout(userObj, login_type, atoi(org_unit)); + long timeout = oilsAuthGetTimeout(userObj, login_type, org_unit); char* string = va_list_to_string("%d.%ld.%ld", (long) getpid(), time(NULL), oilsFMGetObjectId(userObj)); @@ -368,14 +372,18 @@ int oilsAutInternalValidate(osrfMethodContext* ctx) { const char* user_id = jsonObjectGetString(jsonObjectGetKeyConst(args, "user_id")); const char* barcode = jsonObjectGetString(jsonObjectGetKeyConst(args, "barcode")); - const char* org_unit = jsonObjectGetString(jsonObjectGetKeyConst(args, "org_unit")); const char* login_type = jsonObjectGetString(jsonObjectGetKeyConst(args, "login_type")); + int org_unit = jsonObjectGetNumber(jsonObjectGetKeyConst(args, "org_unit")); - if ( !(user_id && login_type && org_unit) ) { + if ( !(user_id && login_type) ) { return osrfAppRequestRespondException( ctx->session, ctx->request, "Missing parameters for method: %s", ctx->method->name ); } + // default to the root org unit if none is provided. + if (org_unit < 1) + org_unit = oilsUtilsGetRootOrgId(); + oilsEvent* response = NULL; jsonObject *userObj = NULL, *params = NULL; char* tmp_str = NULL; @@ -441,7 +449,7 @@ int oilsAutInternalValidate(osrfMethodContext* ctx) { if (!response) { // Still OK // Confirm user has permission to login w/ the requested type. response = oilsAuthCheckLoginPerm( - ctx, atoi(user_id), atoi(org_unit), login_type); + ctx, atoi(user_id), org_unit, login_type); } -- 2.11.0