From ec4ac1b3bcc2eadd76482d0d41d6f12605f54160 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 14 Nov 2021 22:54:29 +0100 Subject: [PATCH] Created a new UserModel, that creates the test admin account with the proper userlevel. --- app/mourne_user_model.cpp | 30 ++++++++++++++++++++++++++++++ app/mourne_user_model.h | 23 +++++++++++++++++++++++ main.cpp | 6 +++--- 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 app/mourne_user_model.cpp create mode 100644 app/mourne_user_model.h diff --git a/app/mourne_user_model.cpp b/app/mourne_user_model.cpp new file mode 100644 index 0000000..10e0523 --- /dev/null +++ b/app/mourne_user_model.cpp @@ -0,0 +1,30 @@ +#include "mourne_user_model.h" + +void MourneUserModel::create_test_users() { + Ref user; + user = UserModel::get_singleton()->create_user(); + + user->rank = 6; + user->name_user_input = "admin"; + user->email_user_input = "admin@admin.com"; + + create_password(user, "Password"); + save_user(user); + + + user = UserModel::get_singleton()->create_user(); + + user->rank = 1; + user->name_user_input = "user"; + user->email_user_input = "user@user.com"; + + create_password(user, "Password"); + save_user(user); +} + +MourneUserModel::MourneUserModel() : + UserModel() { +} + +MourneUserModel::~MourneUserModel() { +} diff --git a/app/mourne_user_model.h b/app/mourne_user_model.h new file mode 100644 index 0000000..a9011f4 --- /dev/null +++ b/app/mourne_user_model.h @@ -0,0 +1,23 @@ +#ifndef MOURNE_USER_MODEL_H +#define MOURNE_USER_MODEL_H + +#include "core/string.h" +#include "core/containers/vector.h" + +#include "modules/users/user_model.h" + +#include "modules/users/user.h" + +class MourneUserModel : public UserModel { + RCPP_OBJECT(MourneUserModel, UserModel); + +public: + virtual void create_test_users(); + + MourneUserModel(); + ~MourneUserModel(); + +protected: +}; + +#endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index 5a0582a..3973f4b 100644 --- a/main.cpp +++ b/main.cpp @@ -20,8 +20,8 @@ #include "backends/hash_hashlib/setup.h" #include "app/mourne_user_controller.h" +#include "app/mourne_user_model.h" #include "modules/users/user.h" -#include "modules/users/user_model.h" #include "core/os/platform.h" #include "platform/platform_initializer.h" @@ -50,8 +50,8 @@ int main(int argc, char **argv, char **envp) { ::SessionManager *session_manager = new ::SessionManager(); //todo init these in the module automatically - UserController *user_controller = new MourneUserController(); - UserModel *user_model = new UserModel(); + MourneUserController *user_controller = new MourneUserController(); + MourneUserModel *user_model = new MourneUserModel(); //user_manager->set_path("./users/"); Settings *settings = new Settings(true);