added database
This commit is contained in:
1 parent
c4ea7a4293
commit
4f67cf11bd
30 files changed
+601
-267
No files matched your search
+21
-13
@@ -1,6 +1,4 @@
|
||||
#include "user.h"
|
||||
#include "jwt.h"
|
||||
#include "utils.h"
|
||||
#include <cJSON.h>
|
||||
#include <mongoose.h>
|
||||
|
||||
@@ -26,15 +24,25 @@ void free_request_with_token(request_with_token *data) {
|
||||
free(data);
|
||||
}
|
||||
|
||||
User *new_user(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;
|
||||
}
|
||||
user->username = strdup(username);
|
||||
user->password = strdup(password);
|
||||
user->email = strdup(email);
|
||||
user->group = strdup(group);
|
||||
user->is_superuser = is_superuser;
|
||||
return user;
|
||||
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;
|
||||
}
|
||||
user->id = id;
|
||||
user->username = strdup(username);
|
||||
user->password = strdup(password);
|
||||
user->email = strdup(email);
|
||||
user->group = strdup(group);
|
||||
user->is_superuser = is_superuser;
|
||||
return user;
|
||||
}
|
||||
|
||||
void free_user(User *user) {
|
||||
free(user->username);
|
||||
free(user->password);
|
||||
free(user->email);
|
||||
free(user->group);
|
||||
free(user);
|
||||
}
|
||||
Reference in new issue
Block a user