Closed ju-ki closed 2 months ago
この変更は、ポスト作成機能における認証プロセスを強化し、APIのセキュリティを改善しています。PostController
では、ユーザーIDの取得方法をリクエストからの直接取得から認証ユーザーのID取得に変更しました。また、テストスイートでは、認証なしでのポスト作成の挙動を検証する新しいテストが追加され、フロントエンドのテストではログインプロセスを統合した成功テストが復活しました。
ファイル | 変更概要 |
---|---|
backend/app/Http/Controllers/API/PostController.php |
create メソッドでの user_id の取得を $request->user_id から Auth::id() に変更。ログ出力を削除。 |
backend/routes/api.php |
/posts/create ルートを auth:sanctum と web ミドルウェアグループ内に移動。認証要件を二重化。 |
backend/tests/Feature/API/PostTest.php |
未認証でのポスト作成挙動を検証する test_api_create_post_without_authentication メソッドを追加。 |
frontend/__test__/pages/CreatePost.spec.tsx |
ログインプロセスを統合した成功時のフォーム送信テストの実装を復活。非同期処理を act でラップ。 |
sequenceDiagram
participant Client
participant Frontend
participant Backend
participant Database
Client->>Frontend: ポスト作成フォーム送信
Frontend->>Backend: API呼び出し (ポスト作成)
Backend->>Database: ポストデータ保存
Database-->>Backend: 確認応答
Backend-->>Frontend: 成功応答
Frontend-->>Client: ポスト作成成功メッセージ
うさぎの目は輝き
コードが変わり、心躍る
認証が強化。安全な道
新しいテストで、夢を描く
投稿もスムーズ、喜びの声
うさぎが跳ねる、コードの中で🌼✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@coderabbitai review
This PR is automatically created by GitHub Actions
Summary by CodeRabbit
新機能
バグ修正
テスト
CreatePost
コンポーネントのフォーム送信の成功テストが改善され、ログインプロセスが組み込まれました。