150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
+
|
#define CSTR(X) cson_string_cstr(cson_value_get_string( cson_object_get(pUser, X ) ))
char const * zName = CSTR("name");
char const * zNameOrig = zName;
char * zNameFree = NULL;
char const * zInfo = CSTR("info");
char const * zCap = CSTR("capabilities");
char const * zPW = CSTR("password");
cson_value const * forceLogout = cson_object_get(pUser, "forceLogout");
int gotFields = 0;
#undef CSTR
cson_int_t uid = cson_value_get_integer( cson_object_get(pUser, "uid") );
Blob sql = empty_blob;
Stmt q = empty_Stmt;
if(!g.perm.Admin && !g.perm.Setup && !g.perm.Password){
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
+
+
+
+
+
+
-
-
+
|
}
if( zInfo ){
blob_appendf(&sql, ", info=%Q", zInfo);
++gotFields;
}
if((g.perm.Admin || g.perm.Setup)
&& forceLogout && cson_value_get_bool(forceLogout)){
blob_append(&sql, ", cookie=NULL, cexpire=NULL", -1);
++gotFields;
}
if(!gotFields){
json_set_err( FSL_JSON_E_MISSING_ARGS,
"Required user data are missing.");
goto error;
}
blob_append(&sql, " WHERE", -1);
assert(uid>0);
blob_appendf(&sql, " uid=%d", uid);
blob_appendf(&sql, " WHERE uid=%d", uid);
free( zNameFree );
/*puts(blob_str(&sql));*/
db_prepare(&q, "%s", blob_str(&sql));
blob_reset(&sql);
db_exec(&q);
db_finalize(&q);
return 0;
|