
- Set up FastAPI application with SQLite database - Create User model with email and password fields - Implement JWT token-based authentication - Add user registration and login endpoints - Create protected user profile endpoints - Configure Alembic for database migrations - Add password hashing with bcrypt - Include CORS middleware and health endpoint - Update README with setup and usage instructions Environment variables required: - SECRET_KEY: JWT secret key for token signing
15 lines
496 B
Python
15 lines
496 B
Python
from fastapi import APIRouter, Depends
|
|
|
|
from app.api.routes.auth import get_current_active_user
|
|
from app.models.user import User
|
|
from app.schemas.user import User as UserSchema
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/me", response_model=UserSchema)
|
|
def read_users_me(current_user: User = Depends(get_current_active_user)):
|
|
return current_user
|
|
|
|
@router.get("/profile", response_model=UserSchema)
|
|
def get_user_profile(current_user: User = Depends(get_current_active_user)):
|
|
return current_user |