Skip to content

Commit

Permalink
logout process finish
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuffugurlu committed Apr 23, 2024
1 parent ab2145d commit e76a7a7
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 7 deletions.
5 changes: 3 additions & 2 deletions API/API/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework_simplejwt.token_blacklist',
'corsheaders',
"Apps.Auth.apps.AuthConfig",
"Apps.Profile.apps.ProfileConfig",
Expand All @@ -61,7 +62,7 @@
"Apps.Chat.apps.ChatConfig",
"Apps.UserStatus.apps.OnlineusersConfig",
"Apps.Request.apps.RequestConfig",
"Apps.Game.apps.GameConfig"
"Apps.Game.apps.GameConfig",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -184,7 +185,7 @@

SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': datetime.timedelta(days=1),
'REFRESH_TOKEN_LIFETIME': datetime.timedelta(days=50),
'REFRESH_TOKEN_LIFETIME': datetime.timedelta(days=30),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,
'UPDATE_LAST_LOGIN': False,
Expand Down
3 changes: 2 additions & 1 deletion API/Apps/Auth/api/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.urls import path
from rest_framework_simplejwt.views import TokenRefreshView, TokenObtainPairView
from rest_framework_simplejwt.views import TokenRefreshView, TokenObtainPairView, TokenBlacklistView
from Apps.Auth.api.views import *
from rest_framework_simplejwt.views import TokenRefreshView

Expand All @@ -11,4 +11,5 @@
path('change-password', change_password, name='change_password'),
path('token/refresh', TokenRefreshView.as_view(), name='token_refresh'),
path('token/temp-token', TokenObtainPairView.as_view(), name='temp_token'),
path('token/blacklist', TokenBlacklistView.as_view(), name='token_blacklist'),
]
4 changes: 3 additions & 1 deletion Backend/static/public/inbox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Backend/static/public/logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Backend/static/scripts/matchmaking.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ async function connectToSocket() {
async function App() {
await connectToSocket();
}

App();
16 changes: 15 additions & 1 deletion Backend/static/scripts/spa.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,4 +758,18 @@ window.addEventListener('popstate', (event) => {
}
);

document.addEventListener('DOMContentLoaded', App);
document.addEventListener('DOMContentLoaded', App);

document.getElementById('logout-wrapper').addEventListener('click', async () => {
const refresh_token = getCookie('refresh_token')
await request(`${API_URL}/token/blacklist`, {
method: 'POST',
body: JSON.stringify({
refresh: refresh_token
}),
});
localStorage.clear()
setCookie('access_token', null, 1);
setCookie('refresh_token', null, 1);
loadPage('/auth/login/')
})
16 changes: 14 additions & 2 deletions Backend/static/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,23 @@ pong-redirect{
transform: translateX(100%);
}
.main-profile-data {
max-width: 112px;
max-width: 180px;
max-height: 80px;
display: flex;
position: absolute;
right: 0;
right: 30px;
top: 0;
z-index: 10;
gap: 5px;
}

.logout-wrapper {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}

.logout-wrapper label {
cursor: pointer;
}
5 changes: 5 additions & 0 deletions Backend/templates/Game/Game.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<ul class="inbox-list" id="inbox-list">
</ul>
</div>
<div class="logout-wrapper" id="logout-wrapper">
<label id="logout-button">
<img src="{% static 'public/logout.svg' %}" alt="cannot load">
</label>
</div>
</div>
<main class="main" id="main">
<div
Expand Down
5 changes: 5 additions & 0 deletions Backend/templates/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<ul class="inbox-list" id="inbox-list">
</ul>
</div>
<div class="logout-wrapper" id="logout-wrapper">
<label id="logout-button">
<img src="{% static 'public/logout.svg' %}" alt="cannot load">
</label>
</div>
</div>
<main class="main" id="main">
<div
Expand Down
5 changes: 5 additions & 0 deletions Backend/templates/matchmaking/matchmaking.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<ul class="inbox-list" id="inbox-list">
</ul>
</div>
<div class="logout-wrapper" id="logout-wrapper">
<label id="logout-button">
<img src="{% static 'public/logout.svg' %}" alt="cannot load">
</label>
</div>
</div>
<div
class="container-fluid position-relative matchmaking-wrapper"
Expand Down
5 changes: 5 additions & 0 deletions Backend/templates/profile/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<ul class="inbox-list" id="inbox-list">
</ul>
</div>
<div class="logout-wrapper" id="logout-wrapper">
<label id="logout-button">
<img src="{% static 'public/logout.svg' %}" alt="cannot load">
</label>
</div>
</div>

<main class="main" id="main">
Expand Down
5 changes: 5 additions & 0 deletions Backend/templates/social/social.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<ul class="inbox-list" id="inbox-list">
</ul>
</div>
<div class="logout-wrapper" id="logout-wrapper">
<label id="logout-button">
<img src="{% static 'public/logout.svg' %}" alt="cannot load">
</label>
</div>
</div>
<main class="main" id="main">
<ul class="chat-options" id="chat-options">
Expand Down

0 comments on commit e76a7a7

Please sign in to comment.