working on adding a entity workflow
This commit is contained in:
61
source/Userdb/userdb.h
Normal file
61
source/Userdb/userdb.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef USER_DB_H
|
||||
#define USER_DB_H
|
||||
|
||||
#define USERDB_USERNAME_MAX_SIZE 32
|
||||
#define USERDB_EMAIL_MAX_SIZE 64
|
||||
#define USERDB_PASSWORD_HASH_MAX_SIZE 128
|
||||
#define USERDB_COOKIE_MAX_SIZE 128
|
||||
#define USERDB_USER_GROUP_MAX_SIZE 30
|
||||
#define USERDB_FIREND_MAX_SIZE 30
|
||||
#define USERDB_MAX_ITEM_COUNT 50
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
char username[USERDB_USERNAME_MAX_SIZE];
|
||||
char email[USERDB_EMAIL_MAX_SIZE];
|
||||
char password_hash[USERDB_PASSWORD_HASH_MAX_SIZE];
|
||||
char user_group[USERDB_USER_GROUP_MAX_SIZE];
|
||||
int user_freads[USERDB_FIREND_MAX_SIZE];
|
||||
int user_items[USERDB_MAX_ITEM_COUNT];
|
||||
int level;
|
||||
int current_xp;
|
||||
int credits;
|
||||
int runs;
|
||||
int active;
|
||||
} Userdb;
|
||||
|
||||
typedef struct {
|
||||
|
||||
const char username[USERDB_USERNAME_MAX_SIZE];
|
||||
const char email[USERDB_EMAIL_MAX_SIZE];
|
||||
const char password_hash[USERDB_PASSWORD_HASH_MAX_SIZE];
|
||||
const char user_group[USERDB_USER_GROUP_MAX_SIZE];
|
||||
|
||||
} UserCreate;
|
||||
|
||||
// Initialize MongoDB client
|
||||
int userdb_init(const char* host, int port);
|
||||
|
||||
// Connect to collection (e.g., "users")
|
||||
int userdb_connect(const char* db_name, const char* collection_name);
|
||||
|
||||
// Create a new user
|
||||
int userdb_create_user(UserCreate user);
|
||||
|
||||
// Retrieve user by username
|
||||
Userdb* userdb_find_user_by_username(const char* username);
|
||||
// Get the user by session_id
|
||||
Userdb* userdb_find_user_by_session_id(const char* session_id);
|
||||
|
||||
// Update user status
|
||||
int userdb_update_user_status(const char* username, int active);
|
||||
|
||||
// Delete user
|
||||
int userdb_delete_user(const char* username);
|
||||
|
||||
// Cleanup
|
||||
void userdb_cleanup();
|
||||
|
||||
|
||||
#endif // !USER_DB_H
|
||||
Reference in New Issue
Block a user