Example #1
0
 /**
  * @todo use options instead, override options()
  * @todo see if admin is availoable
  *
  * @param string $email
  * @param string $password
  */
 public function actionIndex()
 {
     if (!Config::has('last_import_timestamp')) {
         return $this->outputError("You have to run the 'import' process first. run in terminal: ./vendor/bin/luya import");
     }
     if (Config::has('setup_command_timestamp')) {
         return $this->outputError('The setup process already have been started on the ' . date('d.m.Y H:i', Config::get('setup_command_timestamp')) . '. If you want to reinstall your luya project. Drop all tables from your Database, run the migrate command, run the import command and then re-run the setup command');
     }
     $email = $this->prompt('Benutzer E-Mail:');
     $password = $this->prompt('Benutzer Passwort:');
     $firstname = $this->prompt('Vorname:');
     $lastname = $this->prompt('Nachname:');
     if (!$this->confirm("Create a new user ({$email}) with password '{$password}'?")) {
         return $this->outputError('Abort by user.');
     }
     $salt = Yii::$app->getSecurity()->generateRandomString();
     $pw = Yii::$app->getSecurity()->generatePasswordHash($password . $salt);
     $this->insert('admin_user', ['title' => 1, 'firstname' => $firstname, 'lastname' => $lastname, 'email' => $email, 'password' => $pw, 'password_salt' => $salt, 'is_deleted' => 0]);
     $this->insert('admin_group', ['name' => 'Adminstrator', 'text' => 'Administrator Accounts']);
     $this->insert('admin_user_group', ['user_id' => 1, 'group_id' => 1]);
     // get the api-admin-user and api-admin-group auth rights
     $data = Yii::$app->db->createCommand("SELECT * FROM admin_auth WHERE api='api-admin-user' OR api='api-admin-group'")->queryAll();
     foreach ($data as $item) {
         $this->insert('admin_group_auth', ['group_id' => 1, 'auth_id' => $item['id'], 'crud_create' => 1, 'crud_update' => 1, 'crud_delete' => 1]);
     }
     $this->insert('admin_lang', ['name' => 'Deutsch', 'short_code' => 'de', 'is_default' => 1]);
     Config::set('setup_command_timestamp', time());
     return $this->outputSuccess("You can now login with the Email '{$email}' and password '{$password}'.");
 }
Example #2
0
 public function testSettersGetters()
 {
     $this->assertEquals('', Config::get('foo'));
     $this->assertEquals(false, Config::has('foo'));
     $this->assertEquals(true, Config::set('foo', 'bar'));
     $this->assertEquals(true, Config::has('foo'));
     $this->assertEquals('bar', Config::get('foo'));
     $this->assertEquals(true, Config::remove('foo'));
 }