Skip to content

Commit

Permalink
Generate password for first admin user
Browse files Browse the repository at this point in the history
  • Loading branch information
dejwCake committed Oct 16, 2017
1 parent 54371d0 commit 43e6b14
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FillDefaultUserAndPermissions extends Migration
protected $users;
protected $roles;
protected $permissions;
protected $password = 'best package ever';

public function __construct()
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function __construct()
'first_name' => 'Administrator',
'last_name' => 'Administrator',
'email' => '[email protected]',
'password' => Hash::make('best package ever'),
'password' => Hash::make($this->password),
'remember_token' => NULL,
'created_at' => \Carbon\Carbon::now(),
'updated_at' => \Carbon\Carbon::now(),
Expand Down
20 changes: 20 additions & 0 deletions src/Console/Commands/CraftableInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function handle(Filesystem $files)

$this->call('admin-listing:install');

$this->generatePasswordAndUpdateMigration();

$this->info('Craftable installed.');
}

Expand Down Expand Up @@ -84,6 +86,24 @@ private function publishAllVendors() {
]);
}

private function generatePasswordAndUpdateMigration()
{
$password = str_random(10);

$files = File::allFiles(database_path('migrations'));
foreach ($files as $file)
{
if(strpos($file->getFilename(), 'fill_default_user_and_permissions.php') !== false) {
//change database/migrations/*fill_default_user_and_permissions.php to use new password
$this->strReplaceInFile(database_path('migrations/'.$file->getFilename()),
"best package ever",
"".$password."");
$this->info('Admin password is: ' . $password);
break;
}
}
}

private function generateUserStuff(Filesystem $files) {
// TODO this is probably redundant?
// Migrate
Expand Down

0 comments on commit 43e6b14

Please sign in to comment.