Skip to content

fix(nextjs): null user/organization while signed out and ID token fallback without profile fetching - #563

Open
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-signed-out-defaults
Open

fix(nextjs): null user/organization while signed out and ID token fallback without profile fetching#563
DonOmalVindula wants to merge 1 commit into
asgardeo:mainfrom
DonOmalVindula:fix/nextjs-signed-out-defaults

Conversation

@DonOmalVindula

Copy link
Copy Markdown
Contributor

Problem

  • AsgardeoServerProvider initialised user with {} and currentOrganization with {id: '', name: '', orgHandle: ''}. Both are truthy, so <User fallback={...}> and <Organization fallback={...}> never rendered their fallbacks while signed out, useAsgardeo().user could not be checked for truthiness, and <OrganizationSwitcher /> showed a "manage organization" entry for an organization with an empty ID whenever the organization lookup failed. The React SDK keeps both null until they are known.
  • With preferences.user.fetchUserProfile: false the Next.js provider left the user and profile empty; the React SDK falls back to the claims of the ID token.

Fix

  • user and currentOrganization default to null (the client provider prop type follows).
  • When profile fetching is disabled, the user and profile are populated from the ID token claims (extractUserClaimsFromIdToken), mirroring the React SDK.

Testing

  • pnpm lint, tsc --noEmit and pnpm vitest run (60 tests) for @asgardeo/nextjs. The provider change is covered by review; there is no component test setup in this package.

Changeset included (@asgardeo/nextjs patch).

🤖 Generated with Claude Code

…lback without profile fetching

AsgardeoProvider initialised `user` and `currentOrganization` with empty
objects, so `<User fallback>` / `<Organization fallback>` never rendered
their fallbacks and OrganizationSwitcher offered to manage an organization
with an empty ID. With `preferences.user.fetchUserProfile: false` the user
stayed empty, whereas the React SDK falls back to the ID token claims.

- Default both to null, as the React SDK does.
- Populate the user and profile from the ID token claims when profile
  fetching is disabled.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 1b1c3d15-3852-4927-9115-a675939b3973

📥 Commits

Reviewing files that changed from the base of the PR and between 409ebae and 01138c7.

📒 Files selected for processing (3)
  • .changeset/nextjs-signed-out-defaults.md
  • packages/nextjs/src/client/contexts/Asgardeo/AsgardeoProvider.tsx
  • packages/nextjs/src/server/AsgardeoProvider.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@asgardeo-github-bot

Copy link
Copy Markdown

🦋 Changeset detected

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants