Skip to content

Commit

Permalink
Add logout API
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-nghiem-goldenowl committed Dec 10, 2023
1 parent af09a36 commit f162c5f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ Visit `http://127.0.0.1:8000/swagger/` to check API document.

`docker compose up`

## Clean expired token

`python manage.py flushexpiredtokens`

## Database diagram

![Database diagram](db_diagram.png)
3 changes: 2 additions & 1 deletion authentication/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.urls import path
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView, TokenBlacklistView

from authentication.views import RegisterView

urlpatterns = [
path("login/", TokenObtainPairView.as_view(), name="token_obtain_pair"),
path('logout/', TokenBlacklistView.as_view(), name='token_blacklist'),
path("token/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
path("register/", RegisterView.as_view(), name="auth_register"),
]
1 change: 1 addition & 0 deletions django_template/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"django.contrib.staticfiles",
"rest_framework",
"rest_framework_simplejwt",
"rest_framework_simplejwt.token_blacklist",
"django_core",
"drf_yasg",
"django_filters",
Expand Down
2 changes: 1 addition & 1 deletion django_template/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DB_DEV_NAME", "baron"),
"NAME": os.getenv("DB_DEV_NAME", "dev_db"),
"USER": os.getenv("DB_DEV_USER", "postgres"),
"PASSWORD": os.getenv("DB_DEV_PASSWORD", ""),
"HOST": os.getenv("DB_DEV_HOST", "127.0.0.1"),
Expand Down
2 changes: 1 addition & 1 deletion django_template/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.getenv("DB_NAME", "baron"),
"NAME": os.getenv("DB_NAME", "prod_db"),
"USER": os.getenv("DB_USER", "postgres"),
"PASSWORD": os.getenv("DB_PASSWORD", ""),
"HOST": os.getenv("DB_HOST", "127.0.0.1"),
Expand Down

0 comments on commit f162c5f

Please sign in to comment.