getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.51k stars 1.4k forks source link

Batch create multiple user accounts #3768

Closed chriswainformatik closed 10 months ago

chriswainformatik commented 11 months ago

Is there a way to quickly create multiple user accounts? Like a csv upload? Or would it be safe to create the yaml files by a script and upload them to the user accounts directory?

u07 commented 11 months ago

Working with raw files directly was always fine in Grav. But there are also some api for managing users. I dunno, it may be what you need: https://learn.getgrav.org/17/api#class-gravcommonflextypesusersusercollection

chriswainformatik commented 10 months ago

Unfortunately, I was not able to create raw yaml files for user accounts. I don't know what class from the api to use in order to create a account file. Could someone point me in the right direction how this can be done?

rhukster commented 10 months ago

It's not complicated: https://github.com/getgrav/grav-plugin-login#manual-user-creation

chriswainformatik commented 10 months ago

Ok you are right but the example is without a password. I didn't manage to create a valid password hash. How do I do that?

rhukster commented 10 months ago

Simply put:

password: YourPasswordPlainText

Grav will automically replace this with a hashedPassword when you log in successfully the first time.

chriswainformatik commented 10 months ago

That was exactly the hint I needed! I managed to create multiple accounts from a csv file.