mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Removed the mutex from User. I'm going to change how users work.
This commit is contained in:
parent
ccec3f7dde
commit
1ff328a3e6
@ -8,8 +8,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
void DBBasedUser::save() {
|
||||
_mutex.lock();
|
||||
|
||||
QueryBuilder *b = DatabaseManager::get_singleton()->ddb->get_query_builder();
|
||||
|
||||
if (get_id() == 0) {
|
||||
@ -79,15 +77,11 @@ void DBBasedUser::save() {
|
||||
b->run_query();
|
||||
|
||||
delete b;
|
||||
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void DBBasedUser::load() {
|
||||
unregister_sessions();
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
if (get_id() == 0) {
|
||||
return;
|
||||
}
|
||||
@ -134,8 +128,6 @@ void DBBasedUser::load() {
|
||||
|
||||
delete b;
|
||||
|
||||
_mutex.unlock();
|
||||
|
||||
register_sessions();
|
||||
}
|
||||
|
||||
|
@ -149,8 +149,6 @@ void User::register_sessions() {
|
||||
return;
|
||||
}
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
for (int i = 0; i < _sessions.size(); ++i) {
|
||||
HTTPSession *session = new HTTPSession();
|
||||
session->session_id = _sessions[i];
|
||||
@ -158,8 +156,6 @@ void User::register_sessions() {
|
||||
|
||||
sm->add_session(session);
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void User::unregister_sessions() {
|
||||
@ -174,13 +170,9 @@ void User::unregister_sessions() {
|
||||
return;
|
||||
}
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
for (int i = 0; i < _sessions.size(); ++i) {
|
||||
sm->delete_session(_sessions[i]);
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void User::handle_request_default(Request *request) {
|
||||
@ -243,9 +235,7 @@ void User::handle_login_request_default(Request *request) {
|
||||
|
||||
session->add_object("user", user);
|
||||
|
||||
user->_mutex.lock();
|
||||
user->_sessions.push_back(session->session_id);
|
||||
user->_mutex.unlock();
|
||||
|
||||
user->save();
|
||||
|
||||
@ -630,8 +620,6 @@ void User::handle_password_reset_request(Request *request) {
|
||||
void User::handle_logout_request(Request *request) {
|
||||
request->remove_cookie("session_id");
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
for (int i = 0; i < _sessions.size(); ++i) {
|
||||
if (_sessions[i] == request->session->session_id) {
|
||||
_sessions[i] = _sessions[_sessions.size() - 1];
|
||||
@ -639,8 +627,6 @@ void User::handle_logout_request(Request *request) {
|
||||
}
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
|
||||
save();
|
||||
|
||||
SessionManager::get_singleton()->delete_session(request->session->session_id);
|
||||
|
@ -93,8 +93,6 @@ protected:
|
||||
static FormValidator *_login_validator;
|
||||
static FormValidator *_registration_validator;
|
||||
static FormValidator *_profile_validator;
|
||||
|
||||
std::mutex _mutex;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user