Fossil SCM
minor cleanup to the last commit, added a TODO note.
Commit
14ed7070674729a3724141d8591f029169323a8f
Parent
bd9c3b3acabc78a…
1 file changed
+10
-6
+10
-6
| --- src/json_user.c | ||
| +++ src/json_user.c | ||
| @@ -186,10 +186,14 @@ | ||
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | /* |
| 189 | 189 | Todo: reserve the uid=-1 to mean that the user should be created |
| 190 | 190 | by this request. |
| 191 | + | |
| 192 | + Todo: when changing an existing user's name we need to invalidate | |
| 193 | + or recalculate the login hash because the user's name is part of | |
| 194 | + the hash. | |
| 191 | 195 | */ |
| 192 | 196 | |
| 193 | 197 | /* Maintenance note: all error-returns from here on out should go |
| 194 | 198 | via goto error in order to clean up. |
| 195 | 199 | */ |
| @@ -295,19 +299,19 @@ | ||
| 295 | 299 | PROP("password"); |
| 296 | 300 | PROP("info"); |
| 297 | 301 | PROP("capabilities"); |
| 298 | 302 | #undef PROP |
| 299 | 303 | |
| 300 | -#define PROP(LK) b = json_find_option_bool(LK,NULL,NULL,-1); \ | |
| 301 | - if(b>=0){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 | |
| 302 | - PROP("forceLogout"); | |
| 304 | +#define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \ | |
| 305 | + if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 | |
| 306 | + PROP("forceLogout",-1); | |
| 303 | 307 | #undef PROP |
| 304 | 308 | |
| 305 | -#define PROP(LK) i = json_find_option_int(LK,NULL,NULL,-1); \ | |
| 306 | - if(i>=0){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 | |
| 307 | - PROP("uid"); | |
| 309 | +#define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ | |
| 310 | + if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 | |
| 311 | + PROP("uid",-99); | |
| 308 | 312 | #undef PROP |
| 309 | 313 | json_user_update_from_json( u ); |
| 310 | 314 | cson_free_object(u); |
| 311 | 315 | } |
| 312 | 316 | return NULL; |
| 313 | 317 | } |
| 314 | 318 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -186,10 +186,14 @@ | |
| 186 | } |
| 187 | } |
| 188 | /* |
| 189 | Todo: reserve the uid=-1 to mean that the user should be created |
| 190 | by this request. |
| 191 | */ |
| 192 | |
| 193 | /* Maintenance note: all error-returns from here on out should go |
| 194 | via goto error in order to clean up. |
| 195 | */ |
| @@ -295,19 +299,19 @@ | |
| 295 | PROP("password"); |
| 296 | PROP("info"); |
| 297 | PROP("capabilities"); |
| 298 | #undef PROP |
| 299 | |
| 300 | #define PROP(LK) b = json_find_option_bool(LK,NULL,NULL,-1); \ |
| 301 | if(b>=0){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 |
| 302 | PROP("forceLogout"); |
| 303 | #undef PROP |
| 304 | |
| 305 | #define PROP(LK) i = json_find_option_int(LK,NULL,NULL,-1); \ |
| 306 | if(i>=0){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 |
| 307 | PROP("uid"); |
| 308 | #undef PROP |
| 309 | json_user_update_from_json( u ); |
| 310 | cson_free_object(u); |
| 311 | } |
| 312 | return NULL; |
| 313 | } |
| 314 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -186,10 +186,14 @@ | |
| 186 | } |
| 187 | } |
| 188 | /* |
| 189 | Todo: reserve the uid=-1 to mean that the user should be created |
| 190 | by this request. |
| 191 | |
| 192 | Todo: when changing an existing user's name we need to invalidate |
| 193 | or recalculate the login hash because the user's name is part of |
| 194 | the hash. |
| 195 | */ |
| 196 | |
| 197 | /* Maintenance note: all error-returns from here on out should go |
| 198 | via goto error in order to clean up. |
| 199 | */ |
| @@ -295,19 +299,19 @@ | |
| 299 | PROP("password"); |
| 300 | PROP("info"); |
| 301 | PROP("capabilities"); |
| 302 | #undef PROP |
| 303 | |
| 304 | #define PROP(LK,DFLT) b = json_find_option_bool(LK,NULL,NULL,DFLT); \ |
| 305 | if(DFLT!=b){ cson_object_set(u, LK, cson_value_new_bool(b)); } (void)0 |
| 306 | PROP("forceLogout",-1); |
| 307 | #undef PROP |
| 308 | |
| 309 | #define PROP(LK,DFLT) i = json_find_option_int(LK,NULL,NULL,DFLT); \ |
| 310 | if(DFLT != i){ cson_object_set(u, LK, cson_value_new_integer(i)); } (void)0 |
| 311 | PROP("uid",-99); |
| 312 | #undef PROP |
| 313 | json_user_update_from_json( u ); |
| 314 | cson_free_object(u); |
| 315 | } |
| 316 | return NULL; |
| 317 | } |
| 318 |