diff --git a/core/http/session_manager.cpp b/core/http/session_manager.cpp index a8c1996..f35f4c0 100644 --- a/core/http/session_manager.cpp +++ b/core/http/session_manager.cpp @@ -47,9 +47,15 @@ void SessionManager::delete_session(const std::string &session_id) { _sessions.erase(session_id); for (int i = 0; i < _sessions_vec.size(); ++i) { - if (_sessions_vec[i]->session_id == session_id) { + HTTPSession *sess = _sessions_vec[i]; + + if (sess->session_id == session_id) { + _sessions_vec[i] = _sessions_vec[_sessions_vec.size() - 1]; _sessions_vec.pop_back(); + + delete sess; + return; } } diff --git a/modules/users/user.cpp b/modules/users/user.cpp index baab76a..a3ec7cd 100644 --- a/modules/users/user.cpp +++ b/modules/users/user.cpp @@ -397,7 +397,14 @@ void User::handle_password_reset_request(Request *request) { request->compile_and_send_body(); } void User::handle_logout_request(Request *request) { - request->body += "handle_logout_request"; + request->remove_cookie("session_id"); + + SessionManager::get_singleton()->delete_session(request->session->session_id); + request->session = nullptr; + + HTMLBuilder b; + b.w("Logout successful!"); + request->body += b.result; request->compile_and_send_body(); }