Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
8e7380c8
Commit
8e7380c8
authored
Jul 04, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: extend token lifetime to 2 hours
parent
6f4354e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
4 deletions
+2
-4
middleware.py
authentications/middleware.py
+1
-3
views.py
authentications/views.py
+1
-1
No files found.
authentications/middleware.py
View file @
8e7380c8
...
@@ -27,9 +27,7 @@ class AuthMiddleware(MiddlewareMixin):
...
@@ -27,9 +27,7 @@ class AuthMiddleware(MiddlewareMixin):
near_expired
=
expired_time
-
timedelta
(
minutes
=
5
)
near_expired
=
expired_time
-
timedelta
(
minutes
=
5
)
if
datetime
.
now
()
>=
near_expired
:
if
datetime
.
now
()
>=
near_expired
:
payload
[
"exp"
]
=
(
payload
[
"exp"
]
=
payload
[
"exp"
]
+
timedelta
(
hours
=
2
)
.
total_seconds
()
payload
[
"exp"
]
+
timedelta
(
minutes
=
15
)
.
total_seconds
()
)
new_token
=
jwt
.
encode
(
new_token
=
jwt
.
encode
(
payload
,
settings
.
JWT_SECRET
,
algorithm
=
"HS256"
payload
,
settings
.
JWT_SECRET
,
algorithm
=
"HS256"
)
)
...
...
authentications/views.py
View file @
8e7380c8
...
@@ -25,7 +25,7 @@ class AuthView(TemplateView):
...
@@ -25,7 +25,7 @@ class AuthView(TemplateView):
password
=
form
.
data
[
"password"
],
password
=
form
.
data
[
"password"
],
)
)
expiration_time
=
datetime
.
now
()
+
timedelta
(
minutes
=
15
)
expiration_time
=
datetime
.
now
()
+
timedelta
(
hours
=
2
)
payload
=
{
payload
=
{
"exp"
:
expiration_time
.
timestamp
(),
"exp"
:
expiration_time
.
timestamp
(),
"librarian_id"
:
librarian
.
id
,
"librarian_id"
:
librarian
.
id
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment