In my users collections I got a field called "isSuperAdmin". This field can only be set by another super admin
But at first install there is no user available.
Is there a possibility to check if I'm running payload for the first time?
if you are running payload for the first time, it should ask you to create a user
@kvist__ yes, I know. But I only display some fields within my user configuration page if the user is an admin. And at first-install I want to create an admin. So I have to check if it is the first install page to ignore checks
Hi @dnl.krmr you can achieve this by adding a
beforeChange
hook to your users collection, this hook would check if any users exist, if it is the first user then assign your admin role.
Here is an example:
https://github.com/payloadcms/template-website/blob/main/src/collections/Users/hooks/ensureFirstUserIsAdmin.tsStar
Discord
online
Get help straight from the Payload team with an Enterprise License.