diff --git a/plugins/auth/lang/de_de.lang b/plugins/auth/lang/de_de.lang index eef54670..b1e9f6d5 100644 --- a/plugins/auth/lang/de_de.lang +++ b/plugins/auth/lang/de_de.lang @@ -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: {0} 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 löschen +ycom_sessions_deleted = {0} Session/s wurden gelöscht diff --git a/plugins/auth/lib/ycom_user_session.php b/plugins/auth/lib/ycom_user_session.php index ed1a7b5e..e7b9814a 100644 --- a/plugins/auth/lib/ycom_user_session.php +++ b/plugins/auth/lib/ycom_user_session.php @@ -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; + } } diff --git a/plugins/auth/pages/sessions.php b/plugins/auth/pages/sessions.php index 75ce97f5..9cf9ba08 100644 --- a/plugins/auth/pages/sessions.php +++ b/plugins/auth/pages/sessions.php @@ -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', ''); @@ -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', '', 0, ['', '###VALUE###']);