summaryrefslogtreecommitdiffstats
path: root/database/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'database/sqlite')
-rw-r--r--database/sqlite/administration.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/database/sqlite/administration.c b/database/sqlite/administration.c
index 4ae6047..9f69880 100644
--- a/database/sqlite/administration.c
+++ b/database/sqlite/administration.c
@@ -413,9 +413,9 @@ int eDBadminGetUserInfo(eurephiaCTX *ctx, eurephiaUSERINFO *user) {
uinfo_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, user);
// Query the database, find the user defined in the user map
- uinf = sqlite_query_mapped(ctx,
+ uinf = sqlite_query_mapped(ctx, SQL_SELECT,
"SELECT username, activated, deactivated, last_accessed, uid"
- " FROM openvpn_users", uinfo_map);
+ " FROM openvpn_users", NULL, uinfo_map);
if( uinf == NULL ) {
eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user");
@@ -456,7 +456,27 @@ int eDBadminAddUser(eurephiaCTX *ctx, eurephiaUSERINFO *usrinf) {
}
int eDBadminUpdateUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf) {
- return 0;
+ dbresult *uinf = NULL;
+ eurephiaUSERINFO *srch = NULL;
+ eDBfieldMap *data_map = NULL, *srch_map = NULL;
+
+ assert( (ctx != NULL) && (uid != usrinf->uid) );
+
+ srch = eAdminPopulateUSERINFO(uid, NULL, NULL, NULL, NULL, NULL);
+ srch_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, srch);
+
+ data_map = eDBmkMapping_USERINFO(ctx, tbl_sqlite_users, usrinf);
+
+ // Query the database, find the user defined in the user map
+ uinf = sqlite_query_mapped(ctx, SQL_UPDATE, "UPDATE openvpn_users", data_map, srch_map);
+
+ if( uinf == NULL ) {
+ eurephia_log(ctx, LOG_ERROR, 0, "Error querying the database for a user");
+ return 0;
+ }
+ eDBfreeMapping(srch_map);
+ eDBfreeMapping(data_map);
+ return 1;
}
int eDBadminDeleteUser(eurephiaCTX *ctx, const int uid, eurephiaUSERINFO *usrinf) {