Also removed the sessions vector from User.

This commit is contained in:
Relintai 2021-08-22 22:35:11 +02:00
parent 2d7b9e4fd3
commit 58e3855a4d
3 changed files with 0 additions and 24 deletions

View File

@ -118,15 +118,6 @@ std::string User::to_json(rapidjson::Document *into) {
document->AddMember("password_reset_token", rapidjson::Value(password_reset_token.c_str(), document->GetAllocator()), document->GetAllocator()); document->AddMember("password_reset_token", rapidjson::Value(password_reset_token.c_str(), document->GetAllocator()), document->GetAllocator());
document->AddMember("locked", locked, document->GetAllocator()); document->AddMember("locked", locked, document->GetAllocator());
rapidjson::Value sa(rapidjson::Type::kArrayType);
rapidjson::Document::AllocatorType &allocator = document->GetAllocator();
for (int i = 0; i < sessions.size(); i++) {
sa.PushBack(rapidjson::Value(sessions[i].c_str(), document->GetAllocator()), allocator);
}
document->AddMember("sessions", sa, document->GetAllocator());
if (into) { if (into) {
return ""; return "";
} }
@ -159,12 +150,6 @@ void User::from_json(const std::string &p_data) {
password_reset_token = uobj["password_reset_token"].GetString(); password_reset_token = uobj["password_reset_token"].GetString();
locked = uobj["locked"].GetBool(); locked = uobj["locked"].GetBool();
const rapidjson::Value &sess = uobj["sessions"].GetArray();
for (rapidjson::Value::ConstValueIterator itr = sess.Begin(); itr != sess.End(); ++itr) {
sessions.push_back(itr->GetString());
}
} }
User::User() : User::User() :

View File

@ -5,7 +5,6 @@
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <vector>
class Request; class Request;
class FormValidator; class FormValidator;
@ -21,7 +20,6 @@ public:
std::string post_salt; std::string post_salt;
std::string password_hash; std::string password_hash;
bool banned; bool banned;
std::vector<std::string> sessions;
std::string password_reset_token; std::string password_reset_token;
bool locked; bool locked;

View File

@ -407,13 +407,6 @@ void UserController::handle_password_reset_request(Ref<User> &user, Request *req
void UserController::handle_logout_request(Ref<User> &user, Request *request) { void UserController::handle_logout_request(Ref<User> &user, Request *request) {
request->remove_cookie("session_id"); request->remove_cookie("session_id");
for (int i = 0; i < user->sessions.size(); ++i) {
if (user->sessions[i] == request->session->session_id) {
user->sessions[i] = user->sessions[user->sessions.size() - 1];
user->sessions.pop_back();
}
}
UserModel::get_singleton()->save_user(user); UserModel::get_singleton()->save_user(user);
SessionManager::get_singleton()->delete_session(request->session->session_id); SessionManager::get_singleton()->delete_session(request->session->session_id);