|
|
@ -450,13 +450,13 @@ K_ITEM *users_add(PGconn *conn, char *username, char *emailaddress, |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
bool conned = false; |
|
|
|
bool conned = false; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item; |
|
|
|
K_ITEM *item, *u_item; |
|
|
|
USERS *row; |
|
|
|
USERS *row, *users; |
|
|
|
char *ins; |
|
|
|
char *ins; |
|
|
|
char tohash[64]; |
|
|
|
char tohash[64]; |
|
|
|
uint64_t hash; |
|
|
|
uint64_t hash; |
|
|
|
__maybe_unused uint64_t tmp; |
|
|
|
__maybe_unused uint64_t tmp; |
|
|
|
bool ok = false; |
|
|
|
bool dup, ok = false; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
char *params[8 + HISTORYDATECOUNT]; |
|
|
|
int n, par = 0; |
|
|
|
int n, par = 0; |
|
|
|
|
|
|
|
|
|
|
@ -468,14 +468,30 @@ K_ITEM *users_add(PGconn *conn, char *username, char *emailaddress, |
|
|
|
|
|
|
|
|
|
|
|
DATA_USERS(row, item); |
|
|
|
DATA_USERS(row, item); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STRNCPY(row->username, username); |
|
|
|
|
|
|
|
username_trim(row); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dup = false; |
|
|
|
|
|
|
|
K_RLOCK(users_free); |
|
|
|
|
|
|
|
u_item = users_store->head; |
|
|
|
|
|
|
|
while (u_item) { |
|
|
|
|
|
|
|
DATA_USERS(users, u_item); |
|
|
|
|
|
|
|
if (strcmp(row->usertrim, users->usertrim) == 0) { |
|
|
|
|
|
|
|
dup = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
u_item = u_item->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
K_RUNLOCK(users_free); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dup) |
|
|
|
|
|
|
|
goto unitem; |
|
|
|
|
|
|
|
|
|
|
|
row->userid = nextid(conn, "userid", (int64_t)(666 + (random() % 334)), |
|
|
|
row->userid = nextid(conn, "userid", (int64_t)(666 + (random() % 334)), |
|
|
|
cd, by, code, inet); |
|
|
|
cd, by, code, inet); |
|
|
|
if (row->userid == 0) |
|
|
|
if (row->userid == 0) |
|
|
|
goto unitem; |
|
|
|
goto unitem; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: pre-check the username exists? (to save finding out via a DB error)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
STRNCPY(row->username, username); |
|
|
|
|
|
|
|
row->status[0] = '\0'; |
|
|
|
row->status[0] = '\0'; |
|
|
|
STRNCPY(row->emailaddress, emailaddress); |
|
|
|
STRNCPY(row->emailaddress, emailaddress); |
|
|
|
|
|
|
|
|
|
|
@ -644,6 +660,8 @@ bool users_fill(PGconn *conn) |
|
|
|
if (!ok) |
|
|
|
if (!ok) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
username_trim(row); |
|
|
|
|
|
|
|
|
|
|
|
users_root = add_to_ktree(users_root, item, cmp_users); |
|
|
|
users_root = add_to_ktree(users_root, item, cmp_users); |
|
|
|
userid_root = add_to_ktree(userid_root, item, cmp_userid); |
|
|
|
userid_root = add_to_ktree(userid_root, item, cmp_userid); |
|
|
|
k_add_head(users_store, item); |
|
|
|
k_add_head(users_store, item); |
|
|
|