Fossil SCM
Removed more name-related special-case handling code.
Commit
1a4ca414e90ea1804ea5c542b41fba7d326dd530
Parent
34fc6f098f81a40…
1 file changed
+7
-27
+7
-27
| --- src/json_user.c | ||
| +++ src/json_user.c | ||
| @@ -130,18 +130,11 @@ | ||
| 130 | 130 | if(!g.perm.Admin && !g.perm.Setup){ |
| 131 | 131 | json_set_err(FSL_JSON_E_DENIED, |
| 132 | 132 | "Requires 'a' or 's' privileges."); |
| 133 | 133 | return NULL; |
| 134 | 134 | } |
| 135 | - pUser = json_command_arg(g.json.dispatchDepth+1); | |
| 136 | - if( g.isHTTP && (!pUser || !*pUser) ){ | |
| 137 | - pUser = json_getenv_cstr("name") | |
| 138 | - /* ACHTUNG: fossil apparently internally sets name=user/get/XYZ | |
| 139 | - if we pass the name as part of the path, which is why we check | |
| 140 | - with json_command_path() before trying to get("name"). | |
| 141 | - */; | |
| 142 | - } | |
| 135 | + pUser = json_find_option_cstr2("name", NULL, NULL, g.json.dispatchDepth+1); | |
| 143 | 136 | if(!pUser || !*pUser){ |
| 144 | 137 | json_set_err(FSL_JSON_E_MISSING_ARGS,"Missing 'name' property."); |
| 145 | 138 | return NULL; |
| 146 | 139 | } |
| 147 | 140 | payV = json_load_user_by_name(pUser); |
| @@ -411,36 +404,23 @@ | ||
| 411 | 404 | cson_value * tmpV = NULL; |
| 412 | 405 | char b = -1; |
| 413 | 406 | int i = -1; |
| 414 | 407 | int uid = -1; |
| 415 | 408 | cson_value * payload = NULL; |
| 416 | -#define PROP(LK) str = json_find_option_cstr(LK,NULL,NULL); \ | |
| 409 | +#define PROP(LK,SK) str = json_find_option_cstr(LK,NULL,SK); \ | |
| 417 | 410 | if(str){ cson_object_set(u, LK, json_new_string(str)); } (void)0 |
| 418 | - PROP("password"); | |
| 419 | - PROP("info"); | |
| 420 | - PROP("capabilities"); | |
| 411 | + PROP("name","n"); | |
| 412 | + PROP("password","p"); | |
| 413 | + PROP("info","i"); | |
| 414 | + PROP("capabilities","c"); | |
| 421 | 415 | #undef PROP |
| 422 | - tmpV = json_req_payload_get("name"); | |
| 423 | - if(!tmpV && !g.isHTTP){ | |
| 424 | - /* only do this in CLI mode, to avoid the fossil-internal "name" | |
| 425 | - param from become a user's name. Been there, done that | |
| 426 | - (renamed my account to "user/save"). | |
| 427 | - */ | |
| 428 | - str = json_find_option_cstr("name",NULL,NULL); | |
| 429 | - if(str){ | |
| 430 | - tmpV = json_new_string(str); | |
| 431 | - } | |
| 432 | - } | |
| 433 | - if(tmpV){ | |
| 434 | - cson_object_set(u, "name", tmpV); | |
| 435 | - } | |
| 436 | 416 | #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \ |
| 437 | 417 | if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 |
| 438 | 418 | PROP("forceLogout",-1); |
| 439 | 419 | #undef PROP |
| 440 | 420 | |
| 441 | -#define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ | |
| 421 | +#define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ | |
| 442 | 422 | if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 |
| 443 | 423 | PROP("uid",-99); |
| 444 | 424 | #undef PROP |
| 445 | 425 | if( g.json.reqPayload.o ){ |
| 446 | 426 | cson_object_merge( u, g.json.reqPayload.o, CSON_MERGE_NO_RECURSE ); |
| 447 | 427 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -130,18 +130,11 @@ | |
| 130 | if(!g.perm.Admin && !g.perm.Setup){ |
| 131 | json_set_err(FSL_JSON_E_DENIED, |
| 132 | "Requires 'a' or 's' privileges."); |
| 133 | return NULL; |
| 134 | } |
| 135 | pUser = json_command_arg(g.json.dispatchDepth+1); |
| 136 | if( g.isHTTP && (!pUser || !*pUser) ){ |
| 137 | pUser = json_getenv_cstr("name") |
| 138 | /* ACHTUNG: fossil apparently internally sets name=user/get/XYZ |
| 139 | if we pass the name as part of the path, which is why we check |
| 140 | with json_command_path() before trying to get("name"). |
| 141 | */; |
| 142 | } |
| 143 | if(!pUser || !*pUser){ |
| 144 | json_set_err(FSL_JSON_E_MISSING_ARGS,"Missing 'name' property."); |
| 145 | return NULL; |
| 146 | } |
| 147 | payV = json_load_user_by_name(pUser); |
| @@ -411,36 +404,23 @@ | |
| 411 | cson_value * tmpV = NULL; |
| 412 | char b = -1; |
| 413 | int i = -1; |
| 414 | int uid = -1; |
| 415 | cson_value * payload = NULL; |
| 416 | #define PROP(LK) str = json_find_option_cstr(LK,NULL,NULL); \ |
| 417 | if(str){ cson_object_set(u, LK, json_new_string(str)); } (void)0 |
| 418 | PROP("password"); |
| 419 | PROP("info"); |
| 420 | PROP("capabilities"); |
| 421 | #undef PROP |
| 422 | tmpV = json_req_payload_get("name"); |
| 423 | if(!tmpV && !g.isHTTP){ |
| 424 | /* only do this in CLI mode, to avoid the fossil-internal "name" |
| 425 | param from become a user's name. Been there, done that |
| 426 | (renamed my account to "user/save"). |
| 427 | */ |
| 428 | str = json_find_option_cstr("name",NULL,NULL); |
| 429 | if(str){ |
| 430 | tmpV = json_new_string(str); |
| 431 | } |
| 432 | } |
| 433 | if(tmpV){ |
| 434 | cson_object_set(u, "name", tmpV); |
| 435 | } |
| 436 | #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \ |
| 437 | if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 |
| 438 | PROP("forceLogout",-1); |
| 439 | #undef PROP |
| 440 | |
| 441 | #define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ |
| 442 | if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 |
| 443 | PROP("uid",-99); |
| 444 | #undef PROP |
| 445 | if( g.json.reqPayload.o ){ |
| 446 | cson_object_merge( u, g.json.reqPayload.o, CSON_MERGE_NO_RECURSE ); |
| 447 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -130,18 +130,11 @@ | |
| 130 | if(!g.perm.Admin && !g.perm.Setup){ |
| 131 | json_set_err(FSL_JSON_E_DENIED, |
| 132 | "Requires 'a' or 's' privileges."); |
| 133 | return NULL; |
| 134 | } |
| 135 | pUser = json_find_option_cstr2("name", NULL, NULL, g.json.dispatchDepth+1); |
| 136 | if(!pUser || !*pUser){ |
| 137 | json_set_err(FSL_JSON_E_MISSING_ARGS,"Missing 'name' property."); |
| 138 | return NULL; |
| 139 | } |
| 140 | payV = json_load_user_by_name(pUser); |
| @@ -411,36 +404,23 @@ | |
| 404 | cson_value * tmpV = NULL; |
| 405 | char b = -1; |
| 406 | int i = -1; |
| 407 | int uid = -1; |
| 408 | cson_value * payload = NULL; |
| 409 | #define PROP(LK,SK) str = json_find_option_cstr(LK,NULL,SK); \ |
| 410 | if(str){ cson_object_set(u, LK, json_new_string(str)); } (void)0 |
| 411 | PROP("name","n"); |
| 412 | PROP("password","p"); |
| 413 | PROP("info","i"); |
| 414 | PROP("capabilities","c"); |
| 415 | #undef PROP |
| 416 | #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \ |
| 417 | if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 |
| 418 | PROP("forceLogout",-1); |
| 419 | #undef PROP |
| 420 | |
| 421 | #define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ |
| 422 | if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 |
| 423 | PROP("uid",-99); |
| 424 | #undef PROP |
| 425 | if( g.json.reqPayload.o ){ |
| 426 | cson_object_merge( u, g.json.reqPayload.o, CSON_MERGE_NO_RECURSE ); |
| 427 |