| 1 |
<div class="content-section sessions-tab" id="sessions-list"> |
| 2 |
<div class="section-header"> |
| 3 |
<h2 class="subsection-title">Active Sessions</h2> |
| 4 |
</div> |
| 5 |
|
| 6 |
<p class="form-hint mb-5">These are the devices currently logged in to your account. If you don't recognize a session, revoke it.</p> |
| 7 |
|
| 8 |
{% if sessions.is_empty() %} |
| 9 |
<p>No active sessions.</p> |
| 10 |
{% else %} |
| 11 |
<table class="data-table sessions-table"> |
| 12 |
<thead> |
| 13 |
<tr> |
| 14 |
<th>Device</th> |
| 15 |
<th>IP Address</th> |
| 16 |
<th>Signed In</th> |
| 17 |
<th>Last Active</th> |
| 18 |
<th></th> |
| 19 |
</tr> |
| 20 |
</thead> |
| 21 |
<tbody> |
| 22 |
{% for s in sessions %} |
| 23 |
<tr> |
| 24 |
<td class="device-cell"> |
| 25 |
{% if let Some(ua) = s.user_agent %}{{ ua }}{% else %}Unknown device{% endif %} |
| 26 |
{% if let Some(current_id) = current_session_id %}{% if s.id == *current_id %}<span class="badge badge-active ml-2">Current</span>{% endif %}{% endif %} |
| 27 |
</td> |
| 28 |
<td>{% if let Some(ip) = s.ip_address %}{{ ip }}{% else %}--{% endif %}</td> |
| 29 |
<td>{{ s.created_at.format("%b %d, %Y %H:%M UTC") }}</td> |
| 30 |
<td>{{ s.last_active_at.format("%b %d, %Y %H:%M UTC") }}</td> |
| 31 |
<td> |
| 32 |
{% if let Some(current_id) = current_session_id %} |
| 33 |
{% if s.id != *current_id %} |
| 34 |
<button class="btn-secondary small" |
| 35 |
hx-delete="/api/users/me/sessions/{{ s.id }}" |
| 36 |
hx-target="#sessions-list" |
| 37 |
hx-swap="outerHTML" |
| 38 |
hx-confirm="Sign out this device?">Sign out</button> |
| 39 |
{% endif %} |
| 40 |
{% else %} |
| 41 |
<button class="btn-secondary small" |
| 42 |
hx-delete="/api/users/me/sessions/{{ s.id }}" |
| 43 |
hx-target="#sessions-list" |
| 44 |
hx-swap="outerHTML" |
| 45 |
hx-confirm="Sign out this device?">Sign out</button> |
| 46 |
{% endif %} |
| 47 |
</td> |
| 48 |
</tr> |
| 49 |
{% endfor %} |
| 50 |
</tbody> |
| 51 |
</table> |
| 52 |
|
| 53 |
{% if sessions.len() > 1 %} |
| 54 |
<div class="mt-4"> |
| 55 |
<button class="btn-secondary" |
| 56 |
hx-delete="/api/users/me/sessions" |
| 57 |
hx-target="#sessions-list" |
| 58 |
hx-swap="outerHTML" |
| 59 |
hx-confirm="Sign out all other devices?">Sign out all other devices</button> |
| 60 |
</div> |
| 61 |
{% endif %} |
| 62 |
{% endif %} |
| 63 |
</div> |
| 64 |
|