feat: add tongtech user management api

This commit is contained in:
gc87
2024-12-13 16:37:58 +08:00
parent 2499657f8d
commit 8671b4baaa
2 changed files with 53 additions and 0 deletions
+15
View File
@@ -99,6 +99,21 @@ void handle_login(nng_aio *aio)
})
}
void handle_add_user(nng_aio *aio)
{
(void) aio;
}
void handle_delete_user(nng_aio *aio)
{
(void) aio;
}
void handle_update_user(nng_aio *aio)
{
(void) aio;
}
void handle_password(nng_aio *aio)
{
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
+38
View File
@@ -372,6 +372,44 @@ void neu_user_free(neu_user_t *user)
}
}
int neu_user_list()
{
return 0;
}
int neu_user_add(const char *name, const char *password)
{
neu_persist_user_info_t *info = NULL;
if (0 != neu_persister_load_user(name, &info)) {
return 1;
}
neu_user_t *user = neu_user_new(name, password);
if (NULL == user) {
return -1;
}
neu_save_user(user);
return 0;
}
int neu_user_update(const char *name, const char *password)
{
neu_user_t *user = neu_load_user(name);
if (NULL == user) {
return -1;
}
neu_user_update_password(user, password);
neu_save_user(user);
return 0;
}
int neu_user_delete(const char *name)
{
return neu_persister_delete_user(name);
}
bool neu_user_check_password(neu_user_t *user, const char *password)
{
char *salt = user->hash + 3;