mirror of
https://github.com/emqx/neuron.git
synced 2026-10-22 01:05:56 +08:00
feat: add tongtech user management api
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user