diff --git a/plugins/restful/normal_handle.c b/plugins/restful/normal_handle.c index b03557c3..71955b76 100644 --- a/plugins/restful/normal_handle.c +++ b/plugins/restful/normal_handle.c @@ -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( diff --git a/plugins/restful/user.c b/plugins/restful/user.c index ed1c9f3c..b77810f9 100644 --- a/plugins/restful/user.c +++ b/plugins/restful/user.c @@ -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;