Revised method for user injection: artisan tinker

This commit is contained in:
Boudewijn 2025-03-03 15:15:31 +01:00
parent 8b69328c85
commit 1be91cc2dd
2 changed files with 15 additions and 13 deletions

View file

@ -46,16 +46,16 @@ ram.runtime = "100M"
default = "all_users"
# for now no credentials configured, make it install first
# [install.user]
# help.en = "The name of the user"
# type = "string"
# [install.email]
# help.en = "The email address used for logging in to the application"
# type = "email"
# [install.password]
# help.en = "Use the help field to add an information for the admin about this question."
# help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
# type = "password"
[install.user]
help.en = "The name of the user"
type = "string"
[install.email]
help.en = "The email address used for logging in to the application"
type = "email"
[install.password]
help.en = "Use the help field to add an information for the admin about this question."
help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
type = "password"
[resources]
# See the packaging documentation for the full set

View file

@ -94,6 +94,8 @@ ynh_composer_exec install --no-dev
#=================================================
ynh_script_progression "configuring $app..."
# Generate a random alfanumeric string as API token
token = $(tr -dc A-Za-z0-9 </dev/urandom | head -c 60)
pushd "$install_dir"
@ -102,12 +104,12 @@ pushd "$install_dir"
"php$php_version" artisan migrate:fresh --seed -n --force
"php$php_version" artisan config:clear -n
"php$php_version" artisan config:cache -n
# "php$php_version" artisan app:create-user "$user" "$email" "$password"
#"php$php_version" artisan app:create-user "$user" "$email" "$password"
# Alternative method: direct injection of credentials using Artisan Tinker:
echo "use App\Models\User; User::create(['name' => '$user', 'email' => '$email' , 'password' => bcrypt ('$password'), 'api_token' => '$token']); " | php artisan tinker
popd
# Try to push create user into artisan tinker
# copy/paste from lychee install, for what it's worth...
# file was touched by artisan, rehash it