mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Removed id from user.
This commit is contained in:
parent
f586f1ae3a
commit
2eb35d644b
@ -12,7 +12,7 @@ void DBBasedUser::save() {
|
|||||||
|
|
||||||
QueryBuilder *b = DatabaseManager::get_singleton()->ddb->get_query_builder();
|
QueryBuilder *b = DatabaseManager::get_singleton()->ddb->get_query_builder();
|
||||||
|
|
||||||
if (id == 0) {
|
if (get_id() == 0) {
|
||||||
b->insert(_table_name, "username, email, rank, pre_salt, post_salt, password_hash, banned, password_reset_token, locked");
|
b->insert(_table_name, "username, email, rank, pre_salt, post_salt, password_hash, banned, password_reset_token, locked");
|
||||||
|
|
||||||
b->values();
|
b->values();
|
||||||
@ -32,7 +32,7 @@ void DBBasedUser::save() {
|
|||||||
|
|
||||||
QueryResult *r = b->run();
|
QueryResult *r = b->run();
|
||||||
|
|
||||||
id = r->get_last_insert_rowid();
|
set_id(r->get_last_insert_rowid());
|
||||||
|
|
||||||
delete r;
|
delete r;
|
||||||
|
|
||||||
@ -49,20 +49,20 @@ void DBBasedUser::save() {
|
|||||||
b->setp("password_reset_token", password_reset_token);
|
b->setp("password_reset_token", password_reset_token);
|
||||||
b->setp("locked", locked);
|
b->setp("locked", locked);
|
||||||
b->cset();
|
b->cset();
|
||||||
b->where()->wp("id", id);
|
b->where()->wp("id", get_id());
|
||||||
|
|
||||||
//b->print();
|
//b->print();
|
||||||
|
|
||||||
b->run_query();
|
b->run_query();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == 0) {
|
if (get_id() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
b->reset();
|
b->reset();
|
||||||
|
|
||||||
b->del(_table_name + "_sessions")->where()->wp("user_id", id)->end_command();
|
b->del(_table_name + "_sessions")->where()->wp("user_id", get_id())->end_command();
|
||||||
//b->print();
|
//b->print();
|
||||||
|
|
||||||
b->end_command();
|
b->end_command();
|
||||||
@ -71,7 +71,7 @@ void DBBasedUser::save() {
|
|||||||
b->reset();
|
b->reset();
|
||||||
|
|
||||||
for (int i = 0; i < sessions.size(); ++i) {
|
for (int i = 0; i < sessions.size(); ++i) {
|
||||||
b->insert(_table_name + "_sessions")->values()->val(id)->val(sessions[i])->cvalues()->end_command();
|
b->insert(_table_name + "_sessions")->values()->val(get_id())->val(sessions[i])->cvalues()->end_command();
|
||||||
}
|
}
|
||||||
|
|
||||||
//b->print();
|
//b->print();
|
||||||
@ -88,7 +88,7 @@ void DBBasedUser::load() {
|
|||||||
|
|
||||||
_mutex.lock();
|
_mutex.lock();
|
||||||
|
|
||||||
if (id == 0) {
|
if (get_id() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ void DBBasedUser::load() {
|
|||||||
b->select("username, email, rank, pre_salt, post_salt, password_hash, banned, password_reset_token, locked");
|
b->select("username, email, rank, pre_salt, post_salt, password_hash, banned, password_reset_token, locked");
|
||||||
b->from(_table_name);
|
b->from(_table_name);
|
||||||
|
|
||||||
b->where()->wp("id", id);
|
b->where()->wp("id", get_id());
|
||||||
|
|
||||||
b->end_command();
|
b->end_command();
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ void DBBasedUser::load() {
|
|||||||
|
|
||||||
b->select("session_id");
|
b->select("session_id");
|
||||||
b->from(_table_name + "_sessions");
|
b->from(_table_name + "_sessions");
|
||||||
b->where()->wp("user_id", id);
|
b->where()->wp("user_id", get_id());
|
||||||
b->end_command();
|
b->end_command();
|
||||||
|
|
||||||
r = b->run();
|
r = b->run();
|
||||||
@ -190,9 +190,11 @@ void DBBasedUser::load_all() {
|
|||||||
|
|
||||||
while (r->next_row()) {
|
while (r->next_row()) {
|
||||||
DBBasedUser *u = new DBBasedUser();
|
DBBasedUser *u = new DBBasedUser();
|
||||||
u->id = r->get_cell_int(0);
|
u->set_id(r->get_cell_int(0));
|
||||||
u->load();
|
u->load();
|
||||||
|
|
||||||
|
//u->to_json();
|
||||||
|
|
||||||
UserManager::get_singleton()->add_user(u);
|
UserManager::get_singleton()->add_user(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ void FileBasedUser::save() {
|
|||||||
rapidjson::Document document;
|
rapidjson::Document document;
|
||||||
document.SetObject();
|
document.SetObject();
|
||||||
|
|
||||||
document.AddMember("id", id, document.GetAllocator());
|
document.AddMember("id", get_id(), document.GetAllocator());
|
||||||
|
|
||||||
document.AddMember("name", rapidjson::Value(nameui.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("email", rapidjson::Value(emailui.c_str(), document.GetAllocator()), document.GetAllocator());
|
||||||
@ -93,7 +93,7 @@ void FileBasedUser::load() {
|
|||||||
|
|
||||||
rapidjson::Value uobj = data.GetObject();
|
rapidjson::Value uobj = data.GetObject();
|
||||||
|
|
||||||
id = uobj["id"].GetInt();
|
set_id(uobj["id"].GetInt());
|
||||||
nameui = uobj["name"].GetString();
|
nameui = uobj["name"].GetString();
|
||||||
emailui = uobj["email"].GetString();
|
emailui = uobj["email"].GetString();
|
||||||
rank = uobj["rank"].GetInt();
|
rank = uobj["rank"].GetInt();
|
||||||
|
@ -26,7 +26,7 @@ void User::load(const std::string &p_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void User::load(const int p_id) {
|
void User::load(const int p_id) {
|
||||||
id = p_id;
|
set_id(p_id);
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
@ -630,7 +630,6 @@ void User::create_validators() {
|
|||||||
User::User() :
|
User::User() :
|
||||||
Resource() {
|
Resource() {
|
||||||
|
|
||||||
id = 0;
|
|
||||||
rank = 0;
|
rank = 0;
|
||||||
banned = false;
|
banned = false;
|
||||||
locked = false;
|
locked = false;
|
||||||
|
@ -14,7 +14,6 @@ class User : public Resource {
|
|||||||
RCPP_OBJECT(User, Resource);
|
RCPP_OBJECT(User, Resource);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int id;
|
|
||||||
std::string nameui;
|
std::string nameui;
|
||||||
std::string emailui;
|
std::string emailui;
|
||||||
int rank;
|
int rank;
|
||||||
|
Loading…
Reference in New Issue
Block a user