added update user change user and change password

This commit is contained in:
wt committed 2025-08-23 00:30:45 +07:00
1 parent 33e8bed178
commit 9c3a8d796a
14 files changed
+278 -45

No files matched your search

+17 -6
View File
@@ -24,8 +24,8 @@ void free_request_with_token(request_with_token *data) {
free(data);
}
User *new_user(int id, const char *username, const char *password, const char *email,
const char *group, bool is_superuser) {
User *new_user(int id, const char *username, const char *password,
const char *email, const char *group, bool is_superuser) {
User *user = malloc(sizeof(User));
if (user == NULL) {
return NULL;
@@ -40,9 +40,20 @@ User *new_user(int id, const char *username, const char *password, const char *e
}
void free_user(User *user) {
free(user->username);
free(user->password);
free(user->email);
free(user->group);
if (!user) {
return;
}
if (user->username != nullptr) {
free(user->username);
}
if (user->password != nullptr) {
free(user->password);
}
if (user->email != nullptr) {
free(user->email);
}
if (user->group != nullptr) {
free(user->group);
}
free(user);
}