Skip to content

Commit

Permalink
変数名をuser_idからemailに修正
Browse files Browse the repository at this point in the history
  • Loading branch information
furutahidehiko committed Mar 21, 2024
1 parent a3fa691 commit 3480947
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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に登録<br>※DBの中身を初期化してから実施すること |

Expand All @@ -38,5 +38,4 @@

### 動作確認
URL: http://localhost:8000
確認内容: Swagger UIの画面が表示されることを確認。これが表示されれば、アプリケーションが正しく起動している証拠です。

確認内容: Swagger UIの画面が表示されることを確認。これが表示されれば、アプリケーションが正しく起動している証拠です。
2 changes: 1 addition & 1 deletion application/config/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class JWTSettings(BaseSettings):
"""JWTトークンの署名に使用するアルゴリズム"""

JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 9
"""アクセストークンの有効期限()"""
"""アクセストークンの有効期限(時間)"""

JWT_REFRESH_TOKEN_EXPIRE_MINUTES: int = 90
"""リフレッシュトークンの有効期限(日)"""
Expand Down
8 changes: 4 additions & 4 deletions application/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions application/domain/user/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


async def auth_password(
user_id: str,
email: str,
password: str,
async_session: AsyncSession,
) -> AuthUserResponse:
Expand All @@ -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が異なります",
},
)

Expand Down Expand Up @@ -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))
4 changes: 2 additions & 2 deletions application/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -104,4 +104,4 @@ async def auth_token_router(
"error": "invalid_grant_type",
"error_description": "grant_typeが不明です",
},
)
)

0 comments on commit 3480947

Please sign in to comment.