Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework user sessions system #3000

Merged
merged 9 commits into from
Aug 13, 2022
Prev Previous commit
Next Next commit
Remove users_admin_session stuff
  • Loading branch information
partydragen committed Aug 7, 2022
commit d97eecb3d4493f3e58b669234999abd4313c93bf
4 changes: 3 additions & 1 deletion core/classes/Core/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@ public function logout(): void {
* Process logout if user is admin
*/
public function admLogout(): void {
$this->_db->delete('users_admin_session', ['user_id', $this->data()->id]);
$this->_db->update('users_session', ['user_id', $this->data()->id], [
'active' => 0
]);

Session::delete($this->_admSessionName);
Cookie::delete($this->_cookieName . '_adm');
Expand Down
37 changes: 0 additions & 37 deletions core/installation/includes/upgrade_perform.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,43 +521,6 @@
$errors[] = 'Unable to convert users: ' . $e->getMessage();
}

// User admin session -> user profile wall replies
// User admin sessions
try {
$old = $conn->get('nl1_users_admin_session', ['id', '<>', 0]);
if ($old->count()) {
$old = $old->results();

foreach ($old as $item) {
DB::getInstance()->insert('users_admin_session', [
'id' => $item->id,
'user_id' => $item->user_id,
'hash' => $item->hash
]);
}
}
} catch (Exception $e) {
$errors[] = 'Unable to convert user admin sessions: ' . $e->getMessage();
}

// User sessions
try {
$old = $conn->get('nl1_users_session', ['id', '<>', 0]);
if ($old->count()) {
$old = $old->results();

foreach ($old as $item) {
DB::getInstance()->insert('users_session', [
'id' => $item->id,
'user_id' => $item->user_id,
'hash' => $item->hash
]);
}
}
} catch (Exception $e) {
$errors[] = 'Unable to convert user sessions: ' . $e->getMessage();
}

// Username history
try {
$old = $conn->get('nl1_users_username_history', ['id', '<>', 0]);
Expand Down
1 change: 0 additions & 1 deletion modules/Core/hooks/DeleteUserHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public static function execute(array $params = []): void {
$db->delete('reports_comments', ['commenter_id', $params['user_id']]);

// User sessions
$db->delete('users_admin_session', ['user_id', $params['user_id']]);
$db->delete('users_session', ['user_id', $params['user_id']]);

// Profile fields
Expand Down