Skip to content

Commit

Permalink
[SOA-39] Enable CSRF (#40)
Browse files Browse the repository at this point in the history
* refactor ✨ : enabled CSRF

* fix ✅ (fe): hide feed actions if no authed user in context
  • Loading branch information
mariadriana-deemaze authored Nov 26, 2024
1 parent 4005d4b commit 45448b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/shield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const shieldConfig = defineConfig({
* to learn more
*/
csrf: {
enabled: false,
enabled: true,
exceptRoutes: [],
enableXsrfCookie: false,
enableXsrfCookie: true,
methods: ['POST', 'PUT', 'PATCH', 'DELETE'],
},

Expand Down
2 changes: 1 addition & 1 deletion inertia/components/posts/feed_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function FeedList({
<Loader2 className="h-5 w-5 mr-2 animate-spin text-muted" />
) : (
allPosts?.map((post, index) => (
<PostCard key={index} user={currentUser} post={post} redirect />
<PostCard key={index} user={currentUser} post={post} actions={!!currentUser} redirect />
))
)}
<div className="flex justify-center py-5 w-full min-w-full">
Expand Down
8 changes: 5 additions & 3 deletions inertia/pages/feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export default function Feed({ posts, user }: InferPageProps<FeedController, 'in
<>
<Head title="Feed" />
<FeedList url={route('feed.show').path} currentUser={user} posts={posts} />
<div className="z-10 fixed left-5 bottom-5">
<CreatePost />
</div>
{user && (
<div className="z-10 fixed left-5 bottom-5">
<CreatePost />
</div>
)}
</>
)
}

0 comments on commit 45448b8

Please sign in to comment.