Fossil SCM

Removed more name-related special-case handling code.

stephan 2012-03-18 04:00 trunk
Commit 1a4ca414e90ea1804ea5c542b41fba7d326dd530
1 file changed +7 -27
+7 -27
--- src/json_user.c
+++ src/json_user.c
@@ -130,18 +130,11 @@
130130
if(!g.perm.Admin && !g.perm.Setup){
131131
json_set_err(FSL_JSON_E_DENIED,
132132
"Requires 'a' or 's' privileges.");
133133
return NULL;
134134
}
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);
143136
if(!pUser || !*pUser){
144137
json_set_err(FSL_JSON_E_MISSING_ARGS,"Missing 'name' property.");
145138
return NULL;
146139
}
147140
payV = json_load_user_by_name(pUser);
@@ -411,36 +404,23 @@
411404
cson_value * tmpV = NULL;
412405
char b = -1;
413406
int i = -1;
414407
int uid = -1;
415408
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); \
417410
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");
421415
#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
- }
436416
#define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \
437417
if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0
438418
PROP("forceLogout",-1);
439419
#undef PROP
440420
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); \
442422
if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0
443423
PROP("uid",-99);
444424
#undef PROP
445425
if( g.json.reqPayload.o ){
446426
cson_object_merge( u, g.json.reqPayload.o, CSON_MERGE_NO_RECURSE );
447427
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button