Skip to content

Commit

Permalink
Alle FE Sessions können auf einen Schlag gelöscht werden #476
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Mar 14, 2024
1 parent 9edc0cb commit ad1e4c2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/auth/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ ycom_impersonate_alert = Eine Session für den User (id=___id___) erstellen und

ycom_session_added_ready_to_login = Session wurde angelegt. Bitte hier einloggen: <a href="{0}" target="_blank" rel="noopener noreferrer">{0}</a>
ycom_session_could_not_been_added = Session konnte nicht angelegt werden, weil der User inaktiv ist.
ycom_user_session_delete_all_sessions_link = Alle Sessions <a href="{0}">löschen</a>
ycom_sessions_deleted = {0} Session/s wurden gelöscht
8 changes: 8 additions & 0 deletions plugins/auth/lib/ycom_user_session.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,12 @@ public static function sessionRegenerated(rex_extension_point $ep): void
->setValue('session_id', rex_type::string($ep->getParam('new_id')))
->update();
}

public static function deleteAllSessions(): bool
{
$sql = rex_sql::factory()
->setTable(rex::getTable('ycom_user_session'))
->delete();
return $sql->getRows() > 0;
}
}
6 changes: 6 additions & 0 deletions plugins/auth/pages/sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

$func = rex_request('func', 'string', '');
switch ($func) {
case 'ycom_user_delete_sessions':
$amount = (int) rex_ycom_user_session::deleteAllSessions();
echo rex_view::success($this->i18n('sessions_deleted', $amount));
break;
case 'remove_session':
// delete session.
$session_id = (string) rex_request('session_id', 'string', '');
Expand Down Expand Up @@ -46,6 +50,8 @@
break;
}

echo rex_view::warning(rex_i18n::rawMsg('ycom_user_session_delete_all_sessions_link', rex_url::currentBackendPage() . '&func=ycom_user_delete_sessions'));

$list = rex_list::factory('SELECT session_id, cookie_key, ip, user_id, useragent, starttime, last_activity from ' . rex::getTablePrefix() . 'ycom_user_session ORDER BY last_activity DESC');

$list->addColumn('remove_session', '<i class="rex-icon rex-icon-delete"></i>', 0, ['<th class="rex-table-icon"></th>', '<td class="rex-table-icon">###VALUE###</td>']);
Expand Down

0 comments on commit ad1e4c2

Please sign in to comment.