Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user is undefined in BeforeDashboard component after login #8134

Closed
r1tsuu opened this issue Sep 9, 2024 · 3 comments
Closed

user is undefined in BeforeDashboard component after login #8134

r1tsuu opened this issue Sep 9, 2024 · 3 comments
Assignees

Comments

@r1tsuu
Copy link
Member

r1tsuu commented Sep 9, 2024

Link to reproduction

No response

Environment Info

Payload: 3.0.0-beta.100
Next.js: 15.0.0-canary.104
Node: 22.8

Describe the Bug

useAuth().user is undefined in a BeforeDashboard component after login.

record-2024-09-09_18.49.55.mp4

Reproduction Steps

Create BeforeDashboard.tsx:

'use client'

import { useAuth } from '@payloadcms/ui'

const BeforeDashboard = () => {
  const { user } = useAuth()
  return <div>ID: {user.id}</div>
}

export default BeforeDashboard

Add to the root config:

admin: {
      importMap: {
        baseDir: path.resolve(dirname),
      },
      components: {
        beforeDashboard: ['./BeforeDashboard.js'],
      },
    },

Login into the admin panel - you should receive an error about user is undefined.

Adapters and Plugins

No response

@r1tsuu r1tsuu added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Sep 9, 2024
@r1tsuu r1tsuu self-assigned this Sep 9, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Sep 9, 2024
@r1tsuu r1tsuu closed this as completed Sep 10, 2024
@r1tsuu
Copy link
Member Author

r1tsuu commented Sep 10, 2024

Fixed in #8135

r1tsuu added a commit that referenced this issue Sep 10, 2024
## Description

Fixes #8134

- [x] I have read and understand the
[CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md)
document in this repository.

## Type of change

<!-- Please delete options that are not relevant. -->

- [x] Bug fix (non-breaking change which fixes an issue)

## Checklist:

- [x] Existing test suite passes locally with my changes
Copy link
Contributor

🚀 This is included in version v3.0.0-beta.103

Copy link
Contributor

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant