Skip to content

Commit 1effce8

Browse files
committed
feat: add Sign Out button to /account page
1 parent aa9720a commit 1effce8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

public/js/app.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,13 +1327,34 @@ function renderAccount() {
13271327
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="color:var(--text-muted);flex-shrink:0"><path d="M9 18l6-6-6-6"/></svg>
13281328
</div>
13291329
</div>
1330+
1331+
<div class="card account-menu-card" id="account-menu-logout" style="cursor:pointer">
1332+
<div class="account-menu-item">
1333+
<div class="account-menu-icon" style="color:var(--accent-red)">
1334+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4M16 17l5-5-5-5M21 12H9"/></svg>
1335+
</div>
1336+
<div class="account-menu-text">
1337+
<div class="account-menu-title">Sign Out</div>
1338+
<div class="account-menu-desc">Logout from your account</div>
1339+
</div>
1340+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="color:var(--text-muted);flex-shrink:0"><path d="M9 18l6-6-6-6"/></svg>
1341+
</div>
1342+
</div>
13301343
</div>
13311344
`;
13321345

13331346
$('#account-menu-edit').addEventListener('click', () => navigateTo('account/edit'));
13341347
$('#account-menu-links').addEventListener('click', () => navigateTo('account/links'));
13351348
$('#account-menu-logs').addEventListener('click', () => navigateTo('log'));
13361349
$('#account-menu-dangerous').addEventListener('click', () => navigateTo('account/dangerous'));
1350+
$('#account-menu-logout').addEventListener('click', async () => {
1351+
try { await api('/auth/logout', { method: 'POST' }); } catch {}
1352+
state.token = null;
1353+
state.user = null;
1354+
localStorage.removeItem('zh_token');
1355+
localStorage.removeItem('zh_user');
1356+
renderLoginPage();
1357+
});
13371358
}
13381359

13391360
function renderAccountEdit() {

0 commit comments

Comments
 (0)