This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/resources/views/yuuno/settings/advanced/sessions.twig

107 lines
4.5 KiB
Twig

{% extends '@yuuno/settings/advanced/master.twig' %}
{% set mode = 'Sessions' %}
{% block description %}
<p>Session keys are a way of identifying yourself with the system without keeping your password in memory.</p>
<p>If someone finds one of your session keys they could possibly compromise your account, if you see any sessions here that shouldn't be here hit the Kill button to kill the selected session.</p>
<p>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.</p>
{% endblock %}
{% block js %}
<script>
function yuunoEndSession(csrf, id) {
var confirm = new Sakura.Dialogue;
confirm.SetType(Sakura.DialogueType.ConfirmNegative);
confirm.Title = "Session Manager";
confirm.Text = !id ? "You are about to end every active login to your account. Are you sure?" : "Are you sure you want to end this session?";
confirm.AddCallback(Sakura.DialogueButton.Yes, function () {
var ajax = new Sakura.AJAX,
formData = new FormData;
formData.append('session', csrf);
if (id) {
formData.append('id', id);
} else {
formData.append('all', true);
}
ajax.SetUrl("{{ route('settings.advanced.sessions') }}");
ajax.SetFormData(formData);
ajax.AddCallback(200, function () {
var result = ajax.JSON();
confirm.Close();
if (result.error || result.text) {
var error = new Sakura.Dialogue;
error.Title = "Session Manager";
error.Text = result.error || result.text;
error.SetType(Sakura.DialogueType.Info);
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
if (result.go) {
window.location.assign(result.go);
}
});
error.Display();
} else if (result.go) {
window.location.assign(result.go);
}
if (!result.error && id) {
Sakura.DOM.Remove(Sakura.DOM.ID('session-' + id));
}
});
ajax.Start(Sakura.HTTPMethod.POST);
});
confirm.Display();
}
</script>
{% endblock %}
{% block settingsContent %}
<table class="settings__table">
{% for elem in ['thead', 'tfoot'] %}
<{{ elem }}>
<tr>
<th class="settings__table-head" style="width: 100px;">IP</th>
<th class="settings__table-head">Useragent</th>
<th class="settings__table-head">Country</th>
<th class="settings__table-head" style="width: 120px;">Login time</th>
<th class="settings__table-head" style="width: 90px;"></th>
</tr>
</{{ elem }}>
{% endfor %}
<tbody>
{% for usession in sessions %}
<tr class="settings__table-row {% if usession.id == active %}settings__table-row--current{% endif %}" id="session-{{ usession.id }}">
<td class="settings__table-column">
{{ usession.ip }}
</td>
<td class="settings__table-column">
{{ usession.agent }}
</td>
<td class="settings__table-column">
<img src="/images/flags/{{ usession.country|lower }}.png" alt="{{ usession.country }}"> {{ usession.country(true) }}
</td>
<td class="settings__table-column">
<time class="time-ago" datetime="{{ usession.start|date('r') }}">{{ usession.start|date(config('general.date_format')) }}</time>
</td>
<td class="settings__table-column">
<button class="input__button" onclick="yuunoEndSession('{{ session_id() }}', {{ usession.id }})">Kill</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<button class="input__button" onclick="yuunoEndSession('{{ session_id() }}')">Kill all active sessions</button>
{% endblock %}