Is there a recommended way to alter user/etc creation on a new install?

Is there a recommended way to alter which users and such are created on a new install of a CUBA app?

Right now, on a new install/instance, user admin gets created, with password admin as everyone knows. We’d like to be able to change the password that admin gets auto-created with, and also add at least one other user to the new install.

Is there a recommended way to do this?

Hi Jon,

You can add an SQL statement to create additional users or altering existing ones to the 30.create-db.sql file. This script is not updated by CUBA DB generation process and it is the recommended way to add customization to your generated DB.

Hmmm - that script is blank. Is there an example of how I would alter the built-in creation of the admin user (especially the password, since they are not stored plaintext.)

The script is left blank intentionally, because it is for your customizations.

You can have a look at the petclinic example. There is an example of user creation there:

insert into SEC_USER
(ID, VERSION, CREATE_TS, CREATED_BY, UPDATE_TS, UPDATED_BY, DELETE_TS, DELETED_BY, LOGIN, LOGIN_LC, PASSWORD, PASSWORD_ENCRYPTION, NAME, FIRST_NAME, LAST_NAME, MIDDLE_NAME, POSITION_, EMAIL, LANGUAGE_, TIME_ZONE, TIME_ZONE_AUTO, ACTIVE, CHANGE_PASSWORD_AT_LOGON, GROUP_ID, GROUP_NAMES, IP_MASK, SYS_TENANT_ID)
values ('78c1b6c3-f217-dc2e-8af6-e1d502256dd0', 1, '2020-05-07 15:57:26', 'admin', '2020-05-07 15:57:26', null, null, null, 'joy', 'joy', '$2a$10$TiUlTNX6VKpyHgargbleuOOmxF6.tx44r/haVxq/5MVPYdWebo9Ly', 'bcrypt', 'Nurse Joy', 'Nurse', 'Joy', null, null, null, 'en', null, null, true, false, '0fa2b1a5-1d68-4d69-9fbd-dff348347f93', null, null, null);

So, you can use insert statement to create users and update to update admin's password. The simplest way to get the encrypted password - just create users on your test system and copy values. But you also can use some hash generators like this one, use 12 rounds. More information on password hashing you can find in the documentation

Thank you, Andrey.