Skip to content

Commit 47c1621

Browse files
committed
Add support for optional admin account
1 parent e5e66ef commit 47c1621

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

web/src/app/WebApp/Installers/Grav/GravSetup.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,36 @@ class GravSetup extends BaseSetup {
1919

2020
protected $config = [
2121
'form' => [
22-
"ignore this"=>"text",
22+
'admin' => ['type'=>'boolean', 'value'=>false, 'label' => "Create admin account"],
23+
'username' => ['text'=>'admin'],
24+
'password' => 'password',
25+
'email' => 'text'
2326
],
2427
'database' => false,
2528
'resources' => [
2629
'composer' => [ 'src' => 'getgrav/grav', 'dst' => '/']
27-
],
30+
],
2831
];
2932

3033
public function install(array $options = null)
3134
{
3235
parent::install($options);
36+
if ( $options['admin'] == true ){
37+
chdir($this->getDocRoot());
38+
$this -> appcontext -> runUser('v-run-cli-cmd', ['php',
39+
$this->getDocRoot('/bin/gpm'),
40+
'install admin'
41+
], $status);
42+
$this -> appcontext -> runUser('v-run-cli-cmd', ['php',
43+
$this->getDocRoot('/bin/plugin'),
44+
'login new-user',
45+
'-u '.$options['username'],
46+
'-p '.$options['password'],
47+
'-e '.$options['email'],
48+
'-P a',
49+
'-N '.$options['username']
50+
], $status);
51+
}
3352
return (1);
3453
}
3554
}

0 commit comments

Comments
 (0)