diff --git a/app/Controllers/Settings/AdvancedController.php b/app/Controllers/Settings/AdvancedController.php index 4e36b8d..b98e0ae 100644 --- a/app/Controllers/Settings/AdvancedController.php +++ b/app/Controllers/Settings/AdvancedController.php @@ -27,27 +27,30 @@ class AdvancedController extends Controller $all = isset($_POST['all']); if (session_check() && ($id || $all)) { - $redirect = route('settings.advanced.sessions'); - // End all sessions if ($all) { CurrentSession::$user->purgeSessions(); - $message = "Deleted all active session associated with your account!"; - return view('global/information', compact('message', 'redirect')); + return $this->json([ + 'text' => 'Deleted all active session associated with your account!', + 'go' => route('main.index'), + ]); } - // Create the session statement $session = new Session($id); // Check if the session exists if ($session->id < 1 || $session->user !== CurrentSession::$user->id) { - $message = "This session doesn't exist!"; - return view('global/information', compact('message', 'redirect')); + return $this->json(['error' => "This session doesn't exist!"]); } $session->delete(); - return redirect($redirect); + $result = ['error' => null]; + if ($session->id === CurrentSession::$session->id) { + $result['go'] = route('main.index'); + } + + return $this->json($result); } $sessions = CurrentSession::$user->sessions(); diff --git a/resources/views/yuuno/settings/advanced/sessions.twig b/resources/views/yuuno/settings/advanced/sessions.twig index c378d8c..3c37db4 100644 --- a/resources/views/yuuno/settings/advanced/sessions.twig +++ b/resources/views/yuuno/settings/advanced/sessions.twig @@ -8,6 +8,70 @@

If you get logged out after clicking one you've most likely killed your current session, to make it easier to avoid this from happening your current session is highlighted.

{% endblock %} +{% block js %} + +{% endblock %} + {% block settingsContent %} {% for elem in ['thead', 'tfoot'] %} @@ -23,7 +87,7 @@ {% endfor %} {% for usession in sessions %} - + @@ -37,17 +101,11 @@ {% endfor %}
{{ usession.ip }} -
- - -
+
-
- - -
+ {% endblock %}