Created a new UserModel, that creates the test admin account with the proper userlevel.

This commit is contained in:
Relintai 2021-11-14 22:54:29 +01:00
parent c65bc0d6b7
commit ec4ac1b3bc
3 changed files with 56 additions and 3 deletions

30
app/mourne_user_model.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "mourne_user_model.h"
void MourneUserModel::create_test_users() {
Ref<User> 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() {
}

23
app/mourne_user_model.h Normal file
View File

@ -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

View File

@ -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);