Files
payloadcms/packages/next
Riley Langbein ece5a95f64 fix(next): prevent locale upsert when not authenticated (#13621)
### What?

When `?locale=` is present in an admin panel URL and that admin panel
URL is visited in an unauthenticated browser, a runtime error is thrown.

### Why?

`upsertPreferences` relies on `req.user` to successfully create a new
`payload-preferences` document. When an unauthenticated user visits a
URL with a `locale` parameter, `upsertPreferences` is called but
`req.user` is not available.

### How?

Prevent `upsertPreferences` from being called when `req.user` is not
available.

Fixes #13581

Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>
2025-10-02 13:26:01 -07:00
..
2025-07-07 20:00:02 +00:00