Skip to content

Conversation

@yesinkim
Copy link
Member


name: "🚀 Pull Request"
about: PR 생성 시 기본 템플릿
labels: 'needs-review'


📝 PR 타입

  • 버그 수정
  • 신규 기능
  • 문서 업데이트
  • 코드 스타일 업데이트 (포맷팅, 세미콜론 추가 등)
  • 리팩토링
  • 기타

📜 설명

MySQL(Docker)로 DB 를 생성, 회원가입 및 로그인 API 작성하였습니다.

엮인 이슈


🔨 작업 내용

  • /auth/sign-up에 회원가입 api 작성
  • /auth/login에 로그인 api 작성
  • DB 초기화 및 alembic migration 작성

📸 스크린샷


🧑‍💻 테스트 결과

전체 테스트 코드(Python)
import requests
import uuid
import json

# 1. Setup
base_url = "http://localhost:8000/auth"
unique_id = str(uuid.uuid4())[:8]
user_id = f"user_{unique_id}"
password = "test_password_123"

print(f"=== Testing Auth Flow for User: {user_id} ===")

# 2. Sign Up
signup_url = f"{base_url}/sign-up"
signup_payload = {
    "user_id": user_id,
    "password": password
}

print(f"\n1. Attempting Sign Up...")
try:
    signup_response = requests.post(signup_url, json=signup_payload)
    print(f"Status Code: {signup_response.status_code}")
    print(f"Response: {signup_response.json()}")
    
    if signup_response.status_code != 201:
        print("Sign up failed! Stopping test.")
        exit()
except Exception as e:
    print(f"Sign up error: {e}")
    exit()

# 3. Login
login_url = f"{base_url}/login"
# OAuth2PasswordRequestForm expects form data (x-www-form-urlencoded), not JSON
login_data = {
    "username": user_id,  # Note: OAuth2 form uses 'username' field even if we call it user_id
    "password": password
}

print(f"\n2. Attempting Login...")
try:
    login_response = requests.post(login_url, data=login_data)
    print(f"Status Code: {login_response.status_code}")
    
    if login_response.status_code == 200:
        token_data = login_response.json()
        print("Login Successful!")
        print(f"Access Token: {token_data['access_token'][:20]}... (truncated)")
        print(f"Token Type: {token_data['token_type']}")
    else:
        print("Login Failed!")
        print(f"Response: {login_response.text}")

except Exception as e:
    print(f"Login error: {e}")
  • 테스트 결과
=== Testing Auth Flow for User: user_e792e75a ===

1. Attempting Sign Up...
Status Code: 201
Response: {'id': 3, 'user_id': 'user_e792e75a', 'message': 'User created successfully'}

2. Attempting Login...
Status Code: 200
Login Successful!
Access Token: eyJhbGciOiJIUzI1NiIs... (truncated)
Token Type: bearer
---

📅 체크리스트

  • 이해하기 어려운 부분에 주석을 추가했습니다.
  • 관련된 문서를 업데이트했습니다.

@yesinkim yesinkim requested a review from minglet November 27, 2025 12:57
@yesinkim yesinkim linked an issue Nov 27, 2025 that may be closed by this pull request
Copy link
Member

@soohyunme soohyunme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 코멘트 남겨뒀습니다 !
참고해주시고 나머지는 좋은 것 같습니다 !

.env.example Outdated
MYSQL_PASSWORD="root"
MYSQL_HOST="localhost"
MYSQL_DATABASE="jobpt"
SECRET_KEY=3c86b1aa566a885dd571729170794eea7354cd5af85670bd89fa741852b5a897
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# DB
MYSQL_USER=your_mysql_user
MYSQL_PASSWORD=your_mysql_password
MYSQL_HOST=localhost
MYSQL_DATABASE=jobpt

# JWT Secret (필수)
# 아래 명령어로 랜덤 값 하나 생성해서 사용하세요.
# python -c "import secrets; print(secrets.token_hex(32))"
SECRET_KEY=change_me
  • root 보다 좀 더 sample 유저 느낌을 줄 수 있도록 변경
  • 위와 같은 형식으로 README.md 의 내용을 .env.example에 넣는 건 어떨까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 좋습니다 수현님 의견 감사합니다!!👍👍 반영해서 커밋 추가로 올리겠습니다

backend/main.py Outdated
# nltk.download("punkt")
# nltk.download("punkt_tab")
uvicorn.run("main:app", host="0.0.0.0", port=8000)
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

개발 환경일때만 reload=True 해야되지 않을까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

꼼꼼하게 확인해주셔서 감사해요... 테스트 하다가 놓친 것 같숩니다... 같이 반영해놓을게용!

@yesinkim yesinkim changed the base branch from main to dev November 27, 2025 14:10
@soohyunme
Copy link
Member

👍

@yesinkim yesinkim merged commit e35cbbe into dev Nov 27, 2025
@yesinkim yesinkim deleted the feat/signin-api branch November 27, 2025 16:11
@github-actions github-actions bot added merged and removed approved labels Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

회원가입 API 작성 운영 DB 구축

3 participants