Fossil SCM
Added forceLogout option to json/user/save.
Commit
98debcacc87e4861f635ddcecf4fee8554e46543
Parent
080acb91be7b3cd…
1 file changed
+8
-2
+8
-2
| --- src/json_user.c | ||
| +++ src/json_user.c | ||
| @@ -152,10 +152,11 @@ | ||
| 152 | 152 | char const * zNameOrig = zName; |
| 153 | 153 | char * zNameFree = NULL; |
| 154 | 154 | char const * zInfo = CSTR("info"); |
| 155 | 155 | char const * zCap = CSTR("capabilities"); |
| 156 | 156 | char const * zPW = CSTR("password"); |
| 157 | + cson_value const * forceLogout = cson_object_get(pUser, "forceLogout"); | |
| 157 | 158 | int gotFields = 0; |
| 158 | 159 | #undef CSTR |
| 159 | 160 | cson_int_t uid = cson_value_get_integer( cson_object_get(pUser, "uid") ); |
| 160 | 161 | Blob sql = empty_blob; |
| 161 | 162 | Stmt q = empty_Stmt; |
| @@ -234,18 +235,23 @@ | ||
| 234 | 235 | if( zInfo ){ |
| 235 | 236 | blob_appendf(&sql, ", info=%Q", zInfo); |
| 236 | 237 | ++gotFields; |
| 237 | 238 | } |
| 238 | 239 | |
| 240 | + if((g.perm.Admin || g.perm.Setup) | |
| 241 | + && forceLogout && cson_value_get_bool(forceLogout)){ | |
| 242 | + blob_append(&sql, ", cookie=NULL, cexpire=NULL", -1); | |
| 243 | + ++gotFields; | |
| 244 | + } | |
| 245 | + | |
| 239 | 246 | if(!gotFields){ |
| 240 | 247 | json_set_err( FSL_JSON_E_MISSING_ARGS, |
| 241 | 248 | "Required user data are missing."); |
| 242 | 249 | goto error; |
| 243 | 250 | } |
| 244 | - blob_append(&sql, " WHERE", -1); | |
| 245 | 251 | assert(uid>0); |
| 246 | - blob_appendf(&sql, " uid=%d", uid); | |
| 252 | + blob_appendf(&sql, " WHERE uid=%d", uid); | |
| 247 | 253 | free( zNameFree ); |
| 248 | 254 | /*puts(blob_str(&sql));*/ |
| 249 | 255 | db_prepare(&q, "%s", blob_str(&sql)); |
| 250 | 256 | blob_reset(&sql); |
| 251 | 257 | db_exec(&q); |
| 252 | 258 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -152,10 +152,11 @@ | |
| 152 | char const * zNameOrig = zName; |
| 153 | char * zNameFree = NULL; |
| 154 | char const * zInfo = CSTR("info"); |
| 155 | char const * zCap = CSTR("capabilities"); |
| 156 | char const * zPW = CSTR("password"); |
| 157 | int gotFields = 0; |
| 158 | #undef CSTR |
| 159 | cson_int_t uid = cson_value_get_integer( cson_object_get(pUser, "uid") ); |
| 160 | Blob sql = empty_blob; |
| 161 | Stmt q = empty_Stmt; |
| @@ -234,18 +235,23 @@ | |
| 234 | if( zInfo ){ |
| 235 | blob_appendf(&sql, ", info=%Q", zInfo); |
| 236 | ++gotFields; |
| 237 | } |
| 238 | |
| 239 | if(!gotFields){ |
| 240 | json_set_err( FSL_JSON_E_MISSING_ARGS, |
| 241 | "Required user data are missing."); |
| 242 | goto error; |
| 243 | } |
| 244 | blob_append(&sql, " WHERE", -1); |
| 245 | assert(uid>0); |
| 246 | blob_appendf(&sql, " uid=%d", uid); |
| 247 | free( zNameFree ); |
| 248 | /*puts(blob_str(&sql));*/ |
| 249 | db_prepare(&q, "%s", blob_str(&sql)); |
| 250 | blob_reset(&sql); |
| 251 | db_exec(&q); |
| 252 |
| --- src/json_user.c | |
| +++ src/json_user.c | |
| @@ -152,10 +152,11 @@ | |
| 152 | char const * zNameOrig = zName; |
| 153 | char * zNameFree = NULL; |
| 154 | char const * zInfo = CSTR("info"); |
| 155 | char const * zCap = CSTR("capabilities"); |
| 156 | char const * zPW = CSTR("password"); |
| 157 | cson_value const * forceLogout = cson_object_get(pUser, "forceLogout"); |
| 158 | int gotFields = 0; |
| 159 | #undef CSTR |
| 160 | cson_int_t uid = cson_value_get_integer( cson_object_get(pUser, "uid") ); |
| 161 | Blob sql = empty_blob; |
| 162 | Stmt q = empty_Stmt; |
| @@ -234,18 +235,23 @@ | |
| 235 | if( zInfo ){ |
| 236 | blob_appendf(&sql, ", info=%Q", zInfo); |
| 237 | ++gotFields; |
| 238 | } |
| 239 | |
| 240 | if((g.perm.Admin || g.perm.Setup) |
| 241 | && forceLogout && cson_value_get_bool(forceLogout)){ |
| 242 | blob_append(&sql, ", cookie=NULL, cexpire=NULL", -1); |
| 243 | ++gotFields; |
| 244 | } |
| 245 | |
| 246 | if(!gotFields){ |
| 247 | json_set_err( FSL_JSON_E_MISSING_ARGS, |
| 248 | "Required user data are missing."); |
| 249 | goto error; |
| 250 | } |
| 251 | assert(uid>0); |
| 252 | blob_appendf(&sql, " WHERE uid=%d", uid); |
| 253 | free( zNameFree ); |
| 254 | /*puts(blob_str(&sql));*/ |
| 255 | db_prepare(&q, "%s", blob_str(&sql)); |
| 256 | blob_reset(&sql); |
| 257 | db_exec(&q); |
| 258 |