Proper logout button

This commit is contained in:
2023-10-25 01:39:15 +03:00
parent 20dd0f34bf
commit a583f4b765

View File

@@ -63,12 +63,25 @@
<div id="profileSpace"> <div id="profileSpace">
<div id="profileInfo">Hello, {username}</div> <div id="profileInfo">Hello, {username}</div>
<button id="logout" on:click={() => { <div id="logout" role="button"
tabindex="0"
on:click={() => {
deleteCookie('access_token');
deleteCookie('refresh_token');
window.location.href = '/auth/login';
}}
on:keydown={e => {
if (e.key === 'Enter' || e.key === ' ') {
deleteCookie('access_token'); deleteCookie('access_token');
deleteCookie('refresh_token'); deleteCookie('refresh_token');
window.location.href = '/auth/login'; window.location.href = '/auth/login';
}}>Log out</button> }
}}
>
Log out
</div> </div>
</div>
</div> </div>
<style> <style>
@@ -117,6 +130,7 @@
#profileSpace { #profileSpace {
margin-bottom: 20px; margin-bottom: 20px;
display: flex; display: flex;
flex-direction: row;
justify-content: center; justify-content: center;
color:white; color:white;
font-weight: 900; font-weight: 900;