Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/9350-auth-permissions-useauth-guard-both.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
---

Guard both `isAuthenticated` and `user` in the `useAuth` example of
`skills/objectui/guides/auth-permissions.md`, and say why beside it
(objectui#9350). Published skills guidance only; no package is released by
this change.
4 changes: 3 additions & 1 deletion skills/objectui/guides/auth-permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ function App() {

### useAuth hook

Guard `user` on its own, not through `isAuthenticated`: in guest mode (`enabled: false`) and in preview mode, `AuthProvider` hardcodes `isAuthenticated` to `true` while `user` stays `null`, so a signed-in-looking context can still carry no user. The shipped `UserMenu` guards both members the same way.

```typescript
import { useAuth } from '@object-ui/auth';

function UserBadge() {
const { user, isAuthenticated, isLoading, error, signOut } = useAuth();

if (isLoading) return <Spinner />;
if (!isAuthenticated) return <LoginButton />;
if (!isAuthenticated || !user) return <LoginButton />;

return (
<div>
Expand Down
Loading