Possible bug: No user in the collection access > update

default discord avatar
vstarush
4 weeks ago
1 1

Hello,

I ran into the issue that a user is not always available in the access > update function of a collection. For example this code

access: {
        update: ({ req : { user} }) => { 
            console.log('**************************')
            console.log('update')
            console.log(user)
            return true;
        }
    },

Returns this, when I click on a "Save" button of a collection item in the payload UI:


update
undefined


update
{
id: '63410f361ef577238338284f',
name: 'Main',
email: 'test@gmail.com',
createdAt: '2022-10-08T05:48:38.633Z',
updatedAt: '2024-01-21T00:54:04.884Z',
loginAttempts: 0,
collection: 'admins',
_strategy: 'local-jwt'
}

for some reason it runs twice and for some reason, once it doesn't have a "user".
Maybe anyone have an idea on why this could happen?

Payload version: 2.8.2

Thanks,
Vitaly

  • default discord avatar
    vstarush
    4 weeks ago

    Update:

    If anyone struggles with this, add "serverURL" parameter to your "payload.config" file. This solves it.

    Good luck :)

Open the post
Continue the discussion in GitHub
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.