public function actionSetupAdminUser()
{
$finder = \Yii::$container->get(Finder::className());
$admin = $finder->findUserByUsername('admin');
if ($admin === null) {
$email = $this->prompt('E-Mail for application admin user:', ['default' => getenv('APP_ADMIN_EMAIL')]);
$this->action('user/create', [$email, 'admin']);
$password = $this->prompt('Password for application admin user:', ['default' => getenv('APP_ADMIN_PASSWORD')]);
} else {
$password = $this->prompt('Update password for application admin user (leave empty to skip):');
}
if ($password) {
$this->action('user/password', ['admin', $password]);
}
sleep(1);
// confirmation may not succeed without a short pause
$this->action('user/confirm', ['admin']);
}