51 lines
1.5 KiB
C
51 lines
1.5 KiB
C
#pragma once
|
|
|
|
#include <cJSON.h>
|
|
#include <mongoose.h>
|
|
|
|
typedef struct User {
|
|
int id;
|
|
char *username;
|
|
char *email;
|
|
char *password;
|
|
char *group;
|
|
bool is_superuser;
|
|
} User;
|
|
|
|
User *new_user(const char *username, const char *password, const char *email, const char *group, bool is_superuser);
|
|
|
|
typedef struct register_request {
|
|
char *username;
|
|
char *email;
|
|
char *password;
|
|
char *group;
|
|
bool is_superuser;
|
|
char *error;
|
|
} register_request;
|
|
|
|
typedef struct request_with_token {
|
|
char *token;
|
|
cJSON *body;
|
|
char *error;
|
|
} request_with_token;
|
|
|
|
typedef struct get_token_request {
|
|
char *username;
|
|
char *password;
|
|
char *error;
|
|
} get_token_request;
|
|
|
|
request_with_token *new_request_with_token(char *token, cJSON *body,
|
|
char *error);
|
|
void free_request_with_token(request_with_token *data);
|
|
|
|
void get_all_users(struct mg_connection *c, struct mg_http_message *hm);
|
|
void get_user(struct mg_connection *c, struct mg_http_message *hm);
|
|
void delete_user(struct mg_connection *c, struct mg_http_message *hm);
|
|
void add_user(struct mg_connection *c, struct mg_http_message *hm);
|
|
void change_user(struct mg_connection *c, struct mg_http_message *hm);
|
|
void change_password(struct mg_connection *c, struct mg_http_message *hm);
|
|
void register_user(struct mg_connection *c, struct mg_http_message *hm);
|
|
void get_token(struct mg_connection *c, struct mg_http_message *hm);
|
|
void verify_token(struct mg_connection *c, struct mg_http_message *hm);
|