Skip to content

Commit eabe65a

Browse files
author
Nadezhda Zhuzhleva
committed
added logout on the back
1 parent 01de311 commit eabe65a

File tree

15 files changed

+582
-5
lines changed

15 files changed

+582
-5
lines changed

src/.env

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DB_HOST=db_form
2+
DB_NAME=formdb
3+
DB_USER=devuser
4+
DB_PASS=tomate
5+
SECRET_KEY=tomate
6+
DJANGO_SETTINGS_MODULE=app.settings
7+
DOMAIN=domain.com
8+
ALLOWED_HOSTS=192.168.1.38,domain.com,localhost
9+
# CORS_ALLOWED_ORIGINS=https://domain.com/
10+
UID=u-s4t2ud-49dda93360bbb6e3fafcff4fad7f567b99e9a2ab0aa0ad2e113577162c0046a1
11+
SECRET=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
12+
NEXT_SECRET=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
13+
URL_DEBUG=https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-49dda93360bbb6e3fafcff4fad7f567b99e9a2ab0aa0ad2e113577162c0046a1&redirect_uri=http://localhost:8000/login/callback&response_type=code
14+
URL_DEPLOY=https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-49dda93360bbb6e3fafcff4fad7f567b99e9a2ab0aa0ad2e113577162c0046a1&redirect_uri=http://localhost:8000/login/callback&response_type=code
15+
REDIRECT_URI=http://localhost:8000/login/callback

src/app/app/settings.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
'rest_framework',
7676
'rest_framework.authtoken',
7777
'rest_framework_simplejwt',
78+
'rest_framework_simplejwt.token_blacklist',
7879
'drf_spectacular',
7980
'core',
8081
'web',
@@ -119,7 +120,7 @@
119120
SIMPLE_JWT = {
120121
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=300),
121122
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
122-
'ROTATE_REFRESH_TOKENS': False, #what is this ?
123+
'ROTATE_REFRESH_TOKENS': True,
123124
'BLACKLIST_AFTER_ROTATION': True,
124125
'ALGORITHM': 'HS256',
125126
'SIGNING_KEY': SECRET_KEY,
@@ -129,6 +130,7 @@
129130
'USER_ID_CLAIM': 'user_id',
130131
'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
131132
'TOKEN_TYPE_CLAIM': 'token_type',
133+
'TOKEN_BLACKLIST_ENABLED': True, # Enable blacklist feature
132134
}
133135

134136
CHANNEL_LAYERS = {

src/app/core/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class User(AbstractBaseUser, PermissionsMixin):
6161
intra_id = models.PositiveIntegerField(default=0)
6262
# gender =
6363
name = models.CharField(max_length=100, blank=True, null=True)
64-
is_active = models.BooleanField(default=True)
64+
is_active = models.BooleanField(default=False)
6565
is_cancel = models.BooleanField(default=False)
6666
is_staff = models.BooleanField(default=False)
6767
is_42_staf = models.BooleanField(default=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
.card {
3+
border-radius: 6px !important;
4+
background: #ededed !important;
5+
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25) !important;
6+
height: 450px !important;
7+
8+
overflow: scroll !important; /* Add this line if we don't limit the size of the content given(ex: max title 150charcaters etc)*/
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
header {
2+
background-color: #030303;
3+
width: 100%;
4+
height: 14vh;
5+
display: flex;
6+
justify-content: space-between;
7+
align-items: center;
8+
position: fixed;
9+
top: 0;
10+
z-index: 10;
11+
padding-left: 3vw;
12+
padding-right: 3vw;
13+
}
14+
15+
user-forms {
16+
position: absolute; /* Allows positioning using top, left, right, bottom */
17+
left: 0;
18+
top: 14vh;
19+
width: 100%; /* Match the width of the page */
20+
z-index: 5; /* Ensure it's above other content but below overlays */
21+
color: white; /* Optional: Adjust text color */
22+
padding: 1rem; /* Optional: Add padding for content */
23+
}
24+
25+
@media (max-width: 768px) {
26+
user-forms {
27+
top: 10vh;
28+
}
29+
}
30+
31+
@media (max-width: 576px) {
32+
user-forms {
33+
top: 8vh;
34+
}
35+
}
36+
37+
@media (max-width: 480px) {
38+
user-forms {
39+
top: 6vh;
40+
}
41+
}
42+
43+
44+
.user-title-name {
45+
color: white;
46+
font-size: 1.5rem;
47+
font-weight: 700;
48+
font-family: 'Helvetica Neue', sans-serif;
49+
/* Text to mayus */
50+
text-transform: uppercase;
51+
}
52+
53+
54+
.rounded-circle {
55+
border-radius: 50%;
56+
width: 20%;
57+
max-width: 80px;
58+
min-width: 40px;
59+
border: 5px solid white;
60+
box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
61+
}
62+
63+
/* Progress bar */
64+
.progress {
65+
font-size: 0.8rem;
66+
}
67+
68+
69+
@media (max-width: 768px) {
70+
header {
71+
height: 10vh;
72+
}
73+
74+
.user-title-name {
75+
font-size: 1.2rem;
76+
}
77+
78+
.rounded-circle {
79+
width: 15%;
80+
border: 4px solid white;
81+
}
82+
83+
.progress {
84+
font-size: 0.7rem;
85+
}
86+
}
87+
88+
@media (max-width: 576px) {
89+
header {
90+
height: 8vh;
91+
}
92+
93+
.user-title-name {
94+
font-size: 1rem;
95+
}
96+
97+
.rounded-circle {
98+
width: 10%;
99+
border: 4px solid white;
100+
}
101+
102+
.progress {
103+
font-size: 0.6rem;
104+
}
105+
}
106+
107+
@media (max-width: 480px) {
108+
header {
109+
height: 6vh;
110+
}
111+
112+
.user-title-name {
113+
font-size: 0.8rem;
114+
}
115+
116+
.rounded-circle {
117+
width: 8%;
118+
border: 3px solid white;
119+
}
120+
121+
.progress {
122+
font-size: 0.5rem;
123+
}
124+
}
125+
126+
127+
128+
129+
.profile-container {
130+
display: flex;
131+
flex-direction: column;
132+
align-items: left;
133+
justify-content: center;
134+
width: 100%;
135+
padding-left: 2vw;
136+
padding-right: 10vw;
137+
}
138+
139+
140+
.options-container {
141+
display: flex;
142+
flex-direction: column;
143+
align-items: center;
144+
justify-content: center;
145+
width: 20vw;
146+
}
147+
148+
149+
/* Logout button */
150+
.logout-btn {
151+
color: #f3f3f3;
152+
background-color: #ff4747;
153+
border-radius: 5px;
154+
border: none;
155+
cursor: pointer;
156+
font-weight: bold;
157+
font-size: 1rem;
158+
width: 30%;
159+
max-width: 100px;
160+
min-width: 100px;
161+
margin-right: 6vw;
162+
}
163+
164+
.logout-btn:hover {
165+
background-color: #e63636;
166+
}
167+
168+
.logout-btn:focus {
169+
outline: none;
170+
}
171+
172+
173+
@media (max-width: 768px) {
174+
.logout-btn {
175+
width: 25%;
176+
max-width: 80px;
177+
min-width: 80px;
178+
font-size: 0.8rem;
179+
}
180+
}
181+
182+
@media (max-width: 576px) {
183+
.logout-btn {
184+
width: 20%;
185+
max-width: 70px;
186+
min-width: 70px;
187+
font-size: 0.7rem;
188+
}
189+
}
190+
191+
@media (max-width: 480px) {
192+
.logout-btn {
193+
width: 15%;
194+
max-width: 60px;
195+
min-width: 60px;
196+
font-size: 0.6rem;
197+
}
198+
}
199+
200+
201+
.theme-icon {
202+
cursor: pointer;
203+
font-size: 1rem;
204+
color: white;
205+
position: absolute;
206+
right: 2vw;
207+
top: 1vh;
208+
z-index: 10;
209+
/* add a shadow to the icon */
210+
text-shadow: 0 0 10px rgba(255, 255, 255, 1);
211+
/* add a transition effect */
212+
/* remove the default focus effect */
213+
outline: none;
214+
/* postion at center */
215+
display: flex;
216+
justify-content: center;
217+
align-items: center;
218+
219+
/* add a transition effect */
220+
transition: all 0.3s ease;
221+
222+
}
223+
224+
.theme-icon:hover {
225+
color: #c7c7c7;
226+
transform: scale(1.1);
227+
}
228+
229+
.theme-icon:focus {
230+
outline: none;
231+
}
232+
233+
.theme-icon:active {
234+
transform: scale(0.9);
235+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Update progress bar based on form completion
2+
function updateProgress() {
3+
const checkboxes = document.querySelectorAll('.form-check-input');
4+
let completed = 0;
5+
6+
checkboxes.forEach((checkbox) => {
7+
if (checkbox.checked) {
8+
completed += parseInt(checkbox.value);
9+
}
10+
});
11+
12+
const progressBar = document.getElementById('progressBar');
13+
progressBar.style.width = completed + '%';
14+
progressBar.setAttribute('aria-valuenow', completed);
15+
progressBar.textContent = completed + '%';
16+
}
17+
18+
// Log out function
19+
function logout() {
20+
alert('Logging out...');
21+
// const baseUrl = window.location.origin;
22+
// const url = `${baseUrl}/logout`;
23+
// const data {
24+
// access_token: "",
25+
// refresh_token: "",
26+
// }
27+
28+
// fetch(url, {
29+
// method: 'POST',
30+
31+
32+
// })
33+
// .then(response => {
34+
35+
// })
36+
// .catch(error => {
37+
// console.error('There was a problem with the fetch operation:', error);
38+
// });
39+
// // Example: window.location.href = '/login.html';
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const darkModeIcon = document.getElementById('darkModeIcon');
2+
const lightModeIcon = document.getElementById('lightModeIcon');
3+
4+
const switchTheme = () => {
5+
const body = document.body;
6+
7+
if (body.classList.contains('dark-theme')) {
8+
// Switch to light theme
9+
body.classList.remove('dark-theme');
10+
body.classList.add('light-theme');
11+
lightModeIcon.classList.remove('d-none');
12+
darkModeIcon.classList.add('d-none');
13+
} else {
14+
// Switch to dark theme
15+
body.classList.remove('light-theme');
16+
body.classList.add('dark-theme');
17+
darkModeIcon.classList.remove('d-none');
18+
lightModeIcon.classList.add('d-none');
19+
}
20+
};
21+
22+
// Event listeners for theme icons
23+
darkModeIcon.addEventListener('click', switchTheme);
24+
lightModeIcon.addEventListener('click', switchTheme);
Loading

0 commit comments

Comments
 (0)