Search code examples
apostrophe-cms

Cannot Add Admin User


I've been following the steps listed in https://docs.apostrophecms.org/apostrophe/tutorials/getting-started/creating-your-first-project to set up a new project, but have run into an issue. When I try to run

node app apostrophe-users:add admin admin

I get back:

That group does not exist.

With no other warnings or errors. I'm not sure why the admin group doesn't exist, or how to go about creating it. This is using a fresh database. Am I missing a step somewhere?


Solution

  • The group does not exist because, unlike the apostrophe-boilerplate project, your project does not have a groups option configured for the apostrophe-users module. Perhaps you removed it, or perhaps you started from scratch and did not directly use apostrophe-boilerplate.

    In this situation, apostrophe does not force any hardcoded groups on you, and instead lets you manually create them via "Groups" in the admin bar.

    This is great but there is a chicken and egg problem getting started as you have seen.

    The solution to that is to create the group first:

    node app apostrophe-groups:add admin admin
    

    This creates a group called admin with the admin permission, which allows members to do anything.

    Then you can add an admin user:

    node app apostrophe-users:add admin admin
    

    Again though, this is only necessary because you either did not use apostrophe-boilerplate at all, or opted to remove the groups option from apostrophe-users. Which is fine - many sites require that administrators be able to create new groups on the fly, although simpler sites usually don't, which is why we provide an option to lock down just a few instead.