diff --git a/app/Utilities/Installer.php b/app/Utilities/Installer.php index 85331462..20de3d76 100644 --- a/app/Utilities/Installer.php +++ b/app/Utilities/Installer.php @@ -4,6 +4,8 @@ namespace App\Utilities; use App\Jobs\Auth\CreateUser; use App\Jobs\Common\CreateCompany; +use App\Models\Auth\Permission; +use App\Models\Auth\Role; use App\Utilities\Console; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Config; @@ -244,17 +246,31 @@ class Installer 'locale' => $locale, 'enabled' => '1', ])); + + // This application uses one local ledger, so no setup wizard is needed. + setting()->set('wizard.completed', '1'); + setting()->save(); } public static function createUser($email, $password, $locale) { + $role = Role::where('name', SystemAccess::SUPER_ADMIN)->firstOrFail(); + $permission = Permission::firstOrCreate( + ['name' => 'read-admin-panel'], + ['display_name' => 'Read Admin Panel'] + ); + + if (! $role->hasPermission($permission->name)) { + $role->attachPermission($permission); + } + dispatch_sync(new CreateUser([ 'name' => '', 'email' => $email, 'password' => $password, 'locale' => $locale, 'companies' => ['1'], - 'roles' => ['1'], + 'roles' => [$role->id], 'enabled' => '1', ])); } diff --git a/config/database.php b/config/database.php index 6914f878..bd4cb8b0 100644 --- a/config/database.php +++ b/config/database.php @@ -2,6 +2,10 @@ use Illuminate\Support\Str; +$mysqlSslCaOption = class_exists(\Pdo\Mysql::class) + ? \Pdo\Mysql::ATTR_SSL_CA + : \PDO::MYSQL_ATTR_SSL_CA; + return [ /* @@ -77,7 +81,7 @@ return [ 'NO_ENGINE_SUBSTITUTION', ], 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + $mysqlSslCaOption => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], @@ -115,7 +119,7 @@ return [ 'NO_ENGINE_SUBSTITUTION', ], 'options' => extension_loaded('pdo_mysql') ? array_filter([ - PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + $mysqlSslCaOption => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], diff --git a/database/seeds/Permissions.php b/database/seeds/Permissions.php index 5b3c1f1b..3dbcfebf 100644 --- a/database/seeds/Permissions.php +++ b/database/seeds/Permissions.php @@ -26,7 +26,7 @@ class Permissions extends Seeder private function create() { $rows = [ - 'admin' => [ + 'super_admin' => [ 'admin-panel' => 'r', 'api' => 'r', 'auth-profile' => 'r,u', @@ -80,7 +80,7 @@ class Permissions extends Seeder 'widgets-profit-loss' => 'r', 'widgets-receivables' => 'r', ], - 'manager' => [ + 'admin' => [ 'admin-panel' => 'r', 'auth-profile' => 'r,u', 'banking-accounts' => 'c,r,u,d', diff --git a/public/public b/public/public new file mode 120000 index 00000000..945c9b46 --- /dev/null +++ b/public/public @@ -0,0 +1 @@ +. \ No newline at end of file