mirror of
https://github.com/grocy/grocy.git
synced 2025-10-11 08:14:30 +00:00
25 lines
591 B
PHP
25 lines
591 B
PHP
![]() |
<?php
|
||
|
|
||
|
// This is executed inside DatabaseMigrationService class/context
|
||
|
|
||
|
$db = $this->DatabaseService->GetDbConnection();
|
||
|
|
||
|
if (defined('HTTP_USER'))
|
||
|
{
|
||
|
// Migrate old user defined in config file to database
|
||
|
$newUserRow = $db->users()->createRow(array(
|
||
|
'username' => HTTP_USER,
|
||
|
'password' => password_hash(HTTP_PASSWORD, PASSWORD_DEFAULT)
|
||
|
));
|
||
|
$newUserRow->save();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
// Create default user "admin" with password "admin"
|
||
|
$newUserRow = $db->users()->createRow(array(
|
||
|
'username' => 'admin',
|
||
|
'password' => password_hash('admin', PASSWORD_DEFAULT)
|
||
|
));
|
||
|
$newUserRow->save();
|
||
|
}
|