diff --git a/README.md b/README.md index 1995bca..71f7000 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,10 @@ |コマンド|内容| |-----|-----| -|make build |Dockerイメージの作成。開発用のdocker-compose.ymlを指定してビルドを行います。| -|make up |コンテナを起動。このコマンドはdocker-compose upコマンドをラップしており、プロジェクトに必要なサービスコンテナを起動します。| -|make down |コンテナを停止。これはdocker-compose downコマンドのラッパーで、起動しているコンテナを停止し、ネットワークを削除します。| -| make migration |マイグレーションファイルを自動生成。モデルに対して行われた変更を元に新しいマイグレーションファイルを作成します。| +| make build | Dockerイメージの作成。開発用のdocker-compose.ymlを指定してビルドを行います。| +| make up | コンテナを起動。このコマンドはdocker-compose upコマンドをラップしており、プロジェクトに必要なサービスコンテナを起動します。| +| make down | コンテナを停止。これはdocker-compose downコマンドのラッパーで、起動しているコンテナを停止し、ネットワークを削除します。| +| make migration | マイグレーションファイルを自動生成。モデルに対して行われた変更を元に新しいマイグレーションファイルを作成します。| | make upgrade | データベースに最新のマイグレーションを適用。データベースを最新のスキーマに更新します。| | make fixtures | fixtures.jsonの中身をDBに登録
※DBの中身を初期化してから実施すること | @@ -38,5 +38,4 @@ ### 動作確認 URL: http://localhost:8000 -確認内容: Swagger UIの画面が表示されることを確認。これが表示されれば、アプリケーションが正しく起動している証拠です。 - +確認内容: Swagger UIの画面が表示されることを確認。これが表示されれば、アプリケーションが正しく起動している証拠です。 \ No newline at end of file diff --git a/application/config/environment.py b/application/config/environment.py index 2ab3021..f65513d 100644 --- a/application/config/environment.py +++ b/application/config/environment.py @@ -53,7 +53,7 @@ class JWTSettings(BaseSettings): """JWTトークンの署名に使用するアルゴリズム""" JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 9 - """アクセストークンの有効期限(分)""" + """アクセストークンの有効期限(時間)""" JWT_REFRESH_TOKEN_EXPIRE_MINUTES: int = 90 """リフレッシュトークンの有効期限(日)""" diff --git a/application/crud.py b/application/crud.py index b9c624e..e5bffdd 100644 --- a/application/crud.py +++ b/application/crud.py @@ -101,11 +101,11 @@ async def check_follow_exists_by_book_id( return True -async def get_user(db: AsyncSession, user_id: str) -> User: - """指定されたuser_id(メールアドレス)に紐づくユーザー情報を返す関数.""" - print(user_id) +async def get_user(db: AsyncSession, email: str) -> User: + """指定されたメールアドレスに紐づくユーザー情報を返す関数.""" + result = await db.execute( - select(User).where(User.email == user_id), + select(User).where(User.email == email), ) user: User = result.scalar_one_or_none() diff --git a/application/domain/user/auth.py b/application/domain/user/auth.py index 74acaed..fda9774 100644 --- a/application/domain/user/auth.py +++ b/application/domain/user/auth.py @@ -13,7 +13,7 @@ async def auth_password( - user_id: str, + email: str, password: str, async_session: AsyncSession, ) -> AuthUserResponse: @@ -32,14 +32,14 @@ def authenticate_user(user: Optional[User]): return False return user.check_password(password) - user = await get_user(async_session, user_id) + user = await get_user(async_session, email) if not authenticate_user(user): raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail={ "error": "bad_request", - "error_description": "idかpasswordが異なります", + "error_description": "メールアドレスかpasswordが異なります", }, ) @@ -79,4 +79,4 @@ async def auth_token(refresh_token: str) -> AuthUserResponse: }, ) - return await create_token(user_id) + return await create_token(str(user_id)) diff --git a/application/routers.py b/application/routers.py index 7edc4cd..65e325a 100644 --- a/application/routers.py +++ b/application/routers.py @@ -91,7 +91,7 @@ async def auth_token_router( match auth_data.grant_type: case GrantType.PASSWORD.value: return await auth_password( - user_id=auth_data.user_id, + email=auth_data.user_id, password=auth_data.password, async_session=async_session, ) @@ -104,4 +104,4 @@ async def auth_token_router( "error": "invalid_grant_type", "error_description": "grant_typeが不明です", }, - ) + ) \ No newline at end of file