Skip to content

Commit

Permalink
feat:#78 JWT로그인 방식 구현 완료 + 로그인,회원가입 오류 출력
Browse files Browse the repository at this point in the history
  • Loading branch information
test1 committed Jul 24, 2023
1 parent 0140d40 commit 4e13b49
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 297 deletions.
28 changes: 19 additions & 9 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import environ
from pathlib import Path
import os
from datetime import timedelta


# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand All @@ -27,13 +28,13 @@
# SECURITY WARNING: keep the secret key used in production secret!


SECRET_KEY = env('SECRET_KEY')
SECRET_KEY = env("SECRET_KEY")


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['backend','localhost']
ALLOWED_HOSTS = ["backend", "localhost"]


# Application definition
Expand All @@ -49,8 +50,9 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
'corsheaders',
"corsheaders",
"django_prometheus",
"rest_framework_simplejwt",
]

MIDDLEWARE = [
Expand All @@ -62,7 +64,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
'corsheaders.middleware.CorsMiddleware',
"corsheaders.middleware.CorsMiddleware",
"django_prometheus.middleware.PrometheusAfterMiddleware",
]

Expand Down Expand Up @@ -155,10 +157,11 @@
LOGOUT_REDIRECT_URL = "/"


CORS_ORIGIN_WHITELIST = ['http://127.0.0.1:5173'
,'http://localhost:5173'
,'http://frontend:5173'
]
CORS_ORIGIN_WHITELIST = [
"http://127.0.0.1:5173",
"http://localhost:5173",
"http://frontend:5173",
]
CORS_ALLOW_CREDENTIALS = True
# AWS S3 관련 설정 추가
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
Expand All @@ -180,8 +183,15 @@
# STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": [
"DEFAULT_REND`ERER_CLASSES": [
"rest_framework.renderers.JSONRenderer",
"rest_framework.renderers.BrowsableAPIRenderer",
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}

JWT_Key = env("JWT_KEY")
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(seconds=10), # 원하는 만료 시간 설정 (예: 15분)
"REFRESH_TOKEN_LIFETIME": timedelta(days=1), # refresh 토큰 만료 시간 (예: 1일)
}
6 changes: 3 additions & 3 deletions backend/openapi/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.0.3 on 2023-07-19 06:50
# Generated by Django 4.0.3 on 2023-07-22 16:30

from django.conf import settings
from django.db import migrations, models
Expand All @@ -18,8 +18,8 @@ class Migration(migrations.Migration):
name='Novel',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('novel_name', models.CharField(max_length=100)),
('novel_image', models.CharField(max_length=255)),
('novel_name', models.CharField(max_length=100, null=True)),
('novel_image', models.CharField(max_length=255, null=True)),
('status', models.BooleanField(default=True)),
('create_at', models.DateTimeField(auto_now_add=True)),
('udate_at', models.DateTimeField(auto_now=True)),
Expand Down
19 changes: 0 additions & 19 deletions backend/openapi/migrations/0002_alter_chatlog_novel.py

This file was deleted.

18 changes: 0 additions & 18 deletions backend/openapi/migrations/0003_alter_novel_novel_image.py

This file was deleted.

18 changes: 0 additions & 18 deletions backend/openapi/migrations/0004_alter_novel_novel_name.py

This file was deleted.

17 changes: 11 additions & 6 deletions backend/openapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ def __str__(self):

class ChatLog(models.Model):
ROLE_CHOICES = (
('user', 'User'),
('assistant', 'Assistant'),
("user", "User"),
("assistant", "Assistant"),
)
novel = models.ForeignKey(
Novel,
on_delete=models.CASCADE,
related_name="novel_chatlog",
blank=True,
null=True,
)
novel = models.ForeignKey(Novel, on_delete=models.CASCADE, related_name='novel_chatlog', blank=True, null=True)
chat_log = models.TextField()
create_at = models.DateTimeField(auto_now_add=True)
udate_at = models.DateTimeField(auto_now=True)
delete_at = models.DateTimeField(null=True)
role = models.CharField(max_length=10, choices=ROLE_CHOICES, default='user')
role = models.CharField(max_length=10, choices=ROLE_CHOICES, default="user")

def __str__(self):
return self.chat_log

class Meta:
ordering = ['novel', 'create_at']

ordering = ["novel", "create_at"]


class Character(models.Model):
Expand Down
Loading

0 comments on commit 4e13b49

Please sign in to comment.