mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-10 00:52:11 +01:00
Also removed the sessions vector from User.
This commit is contained in:
parent
2d7b9e4fd3
commit
58e3855a4d
@ -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("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) {
|
||||
return "";
|
||||
}
|
||||
@ -159,12 +150,6 @@ void User::from_json(const std::string &p_data) {
|
||||
|
||||
password_reset_token = uobj["password_reset_token"].GetString();
|
||||
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() :
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Request;
|
||||
class FormValidator;
|
||||
@ -21,7 +20,6 @@ public:
|
||||
std::string post_salt;
|
||||
std::string password_hash;
|
||||
bool banned;
|
||||
std::vector<std::string> sessions;
|
||||
std::string password_reset_token;
|
||||
bool locked;
|
||||
|
||||
|
@ -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) {
|
||||
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);
|
||||
|
||||
SessionManager::get_singleton()->delete_session(request->session->session_id);
|
||||
|
Loading…
Reference in New Issue
Block a user