mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Implement logout.
This commit is contained in:
parent
f8ba0b26c5
commit
127563e6ca
@ -47,9 +47,15 @@ void SessionManager::delete_session(const std::string &session_id) {
|
|||||||
_sessions.erase(session_id);
|
_sessions.erase(session_id);
|
||||||
|
|
||||||
for (int i = 0; i < _sessions_vec.size(); ++i) {
|
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[i] = _sessions_vec[_sessions_vec.size() - 1];
|
||||||
_sessions_vec.pop_back();
|
_sessions_vec.pop_back();
|
||||||
|
|
||||||
|
delete sess;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,14 @@ void User::handle_password_reset_request(Request *request) {
|
|||||||
request->compile_and_send_body();
|
request->compile_and_send_body();
|
||||||
}
|
}
|
||||||
void User::handle_logout_request(Request *request) {
|
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();
|
request->compile_and_send_body();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user