mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Postfix the fields in User with "ui" that are input from the user.
This commit is contained in:
parent
78bf94ffb4
commit
af9979d9a7
@ -14,8 +14,8 @@ void DBBasedUser::save() {
|
||||
b->insert(_table_name, "username, email, rank, pre_salt, post_salt, password_hash, banned, password_reset_token, locked");
|
||||
|
||||
b->values();
|
||||
b->eval(name);
|
||||
b->eval(email);
|
||||
b->eval(nameui);
|
||||
b->eval(emailui);
|
||||
b->val(rank);
|
||||
b->val(pre_salt);
|
||||
b->val(post_salt);
|
||||
@ -37,8 +37,8 @@ void DBBasedUser::save() {
|
||||
} else {
|
||||
b->udpate(_table_name);
|
||||
b->set();
|
||||
b->esetp("username", name);
|
||||
b->esetp("email", email);
|
||||
b->esetp("username", nameui);
|
||||
b->esetp("email", emailui);
|
||||
b->setp("rank", rank);
|
||||
b->setp("pre_salt", pre_salt);
|
||||
b->setp("post_salt", post_salt);
|
||||
@ -98,8 +98,8 @@ void DBBasedUser::load() {
|
||||
QueryResult *r = b->run();
|
||||
|
||||
if (r->next_row()) {
|
||||
name = r->get_cell(0);
|
||||
email = r->get_cell(1);
|
||||
nameui = r->get_cell(0);
|
||||
emailui = r->get_cell(1);
|
||||
rank = r->get_cell_int(2);
|
||||
pre_salt = r->get_cell(3);
|
||||
post_salt = r->get_cell(4);
|
||||
|
@ -24,15 +24,15 @@ void FileBasedUser::set_path(const std::string &path) {
|
||||
|
||||
void FileBasedUser::save() {
|
||||
//todo sanitize name!
|
||||
_file_path = _path + name;
|
||||
_file_path = _path + nameui;
|
||||
|
||||
rapidjson::Document document;
|
||||
document.SetObject();
|
||||
|
||||
document.AddMember("id", id, document.GetAllocator());
|
||||
|
||||
document.AddMember("name", rapidjson::Value(name.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
document.AddMember("email", rapidjson::Value(email.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
document.AddMember("name", rapidjson::Value(nameui.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
document.AddMember("email", rapidjson::Value(emailui.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
document.AddMember("rank", rank, document.GetAllocator());
|
||||
document.AddMember("pre_salt", rapidjson::Value(pre_salt.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
document.AddMember("post_salt", rapidjson::Value(post_salt.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||
@ -94,8 +94,8 @@ void FileBasedUser::load() {
|
||||
rapidjson::Value uobj = data.GetObject();
|
||||
|
||||
id = uobj["id"].GetInt();
|
||||
name = uobj["name"].GetString();
|
||||
email = uobj["email"].GetString();
|
||||
nameui = uobj["name"].GetString();
|
||||
emailui = uobj["email"].GetString();
|
||||
rank = uobj["rank"].GetInt();
|
||||
pre_salt = uobj["pre_salt"].GetString();
|
||||
post_salt = uobj["post_salt"].GetString();
|
||||
|
@ -43,8 +43,8 @@ bool User::check_password(const std::string &p_password) {
|
||||
|
||||
void User::create_password(const std::string &p_password) {
|
||||
//todo improve a bit
|
||||
pre_salt = hash_password(name + email);
|
||||
post_salt = hash_password(email + name);
|
||||
pre_salt = hash_password(nameui + emailui);
|
||||
post_salt = hash_password(emailui + nameui);
|
||||
|
||||
password_hash = hash_password(p_password);
|
||||
}
|
||||
@ -238,7 +238,7 @@ void User::handle_register_request_default(Request *request) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (u->email == email_val) {
|
||||
if (u->emailui == email_val) {
|
||||
email_found = true;
|
||||
break;
|
||||
}
|
||||
@ -255,8 +255,8 @@ void User::handle_register_request_default(Request *request) {
|
||||
if (error_str.size() == 0) {
|
||||
user = UserManager::get_singleton()->create_user();
|
||||
|
||||
user->name = uname_val;
|
||||
user->email = email_val;
|
||||
user->nameui = uname_val;
|
||||
user->emailui = email_val;
|
||||
//todo
|
||||
user->rank = 1;
|
||||
user->create_password(pass_val);
|
||||
|
@ -13,8 +13,8 @@ class User : public Object {
|
||||
|
||||
public:
|
||||
int id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
std::string nameui;
|
||||
std::string emailui;
|
||||
int rank;
|
||||
std::string pre_salt;
|
||||
std::string post_salt;
|
||||
|
@ -15,7 +15,7 @@ void UserManager::add_user(User *user) {
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
_users_vec.push_back(user);
|
||||
_users[user->name] = user;
|
||||
_users[user->nameui] = user;
|
||||
}
|
||||
|
||||
void UserManager::remove_user(User *user) {
|
||||
@ -26,7 +26,7 @@ void UserManager::remove_user(User *user) {
|
||||
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
|
||||
_users.erase(user->name);
|
||||
_users.erase(user->nameui);
|
||||
|
||||
for (int i = 0; i < _users_vec.size(); ++i) {
|
||||
if (_users_vec[i] == user) {
|
||||
|
Loading…
Reference in New Issue
Block a user