Skip to content

Commit

Permalink
Web installer
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Oct 22, 2018
1 parent 930510a commit d7f6090
Show file tree
Hide file tree
Showing 61 changed files with 17,025 additions and 108 deletions.
18 changes: 7 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Every time you are making changes in .env file, in order changes to take an effect you need to run:
# php artisan config:cache

APP_URL=https://example.com

# Run the following console command to generate the key: php artisan key:generate
# Otherwise application will show the following error: "Whoops, looks like something went wrong"
APP_KEY=
# Uncomment to enable redirect to HTTPS.
#APP_FORCE_HTTPS=true

# Uncomment to set timezone: https://github.com/freescout-helpdesk/freescout/wiki/PHP-Timezones
# Otherwise default timezone from php.ini will be used.
Expand All @@ -18,11 +16,9 @@ DB_DATABASE=freescout
DB_USERNAME=freescout
DB_PASSWORD=XXX

# Uncomment to see errors in your browser, don't forget to comment it back when debugging finished
#APP_DEBUG=true

# After how many days log records in activity_logs table will be removed
#ACTIVITY_LOGGER_DELETE_RECORDS_OLDER_THAN_DAYS=30
# Run the following console command to generate the key: php artisan key:generate
# Otherwise application will show the following error: "Whoops, looks like something went wrong"
APP_KEY=

# Uncomment to enable redirect to HTTPS.
#APP_FORCE_HTTPS=true
# Uncomment to see errors in your browser, don't forget to comment it back when debugging finished
#APP_DEBUG=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Thumbs.db
/Modules/**/.git
/public/modules
/storage/.ignore_locales
/storage/installed
/tools
45 changes: 45 additions & 0 deletions app/Console/Commands/ClearCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class ClearCache extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'freescout:clear-cache';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Clear application cache and cache config';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->call('clear-compiled');
$this->call('cache:clear');
$this->call('view:clear');
$this->call('config:cache');
}
}
4 changes: 2 additions & 2 deletions app/Console/Commands/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CreateUser extends Command
*
* @var string
*/
protected $description = 'Creates a new user';
protected $description = 'Create a new user';

/**
* Create a new command instance.
Expand Down Expand Up @@ -49,7 +49,7 @@ public function handle()
$fillables = ['role', 'first_name', 'last_name', 'email', 'password'];
foreach ($fillables as $key => $fillable) {
if ($fillable == 'password') {
$user->password = \Hash::make($this->secret(($key + 1).'/'.count($fillables)." User $fillable"));
$user->$fillable = \Hash::make($this->secret(($key + 1).'/'.count($fillables)." User $fillable"));
} elseif ($fillable == 'role') {
$user->$fillable = $this->ask(($key + 1).'/'.count($fillables)." User $fillable (admin/user)", 'admin');
if (!$user->$fillable) {
Expand Down
7 changes: 7 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public function register()
$_SERVER['SERVER_PORT'] = '443';
$this->app['url']->forceScheme('https');
}

// If APP_KEY is not set, redirect to /install.php
if (!\Config::get('app.key') && !app()->runningInConsole()) {
// Not defined here yet
//\Artisan::call("freescout:clear-cache");
redirect('/install.php')->send();
}
}

/**
Expand Down
26 changes: 26 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use App\Mail\PasswordChanged;
use App\Mail\UserInvite;
use App\Email;
use App\Option;
use App\Notifications\WebsiteNotification;
use App\SendLog;
Expand Down Expand Up @@ -614,4 +615,29 @@ public static function getSuperAdmin()
{
return User::where('role', User::ROLE_ADMIN)->first();
}

/**
* Create user.
*/
public static function create($data)
{
$user = new User();

if (empty($data['email']) || empty($data['password'])) {
return false;
}

$user->fill($data);

$user->password = \Hash::make($data['password']);
$user->email = Email::sanitizeEmail($data['email']);

try {
$user->save();
} catch(\Exception $e) {
return false;
}

return true;
}
}
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"nwidart/laravel-modules": "2.7.0",
"tormjens/eventy": "0.5.4",
"barryvdh/laravel-translation-manager": "v0.5.0",
"chumper/zipper": "v1.0.2"
"chumper/zipper": "v1.0.2",
"rachidlaasri/laravel-installer": "4.0.2"
},
"require-dev": {
"barryvdh/laravel-debugbar": "v2.4.3",
Expand All @@ -37,11 +38,20 @@
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/",
"Axn\\Laroute\\Routes\\": "overrides/Axn/Laroute/Routes",
"Webklex\\IMAP\\": "overrides/Webklex/IMAP"
"Axn\\Laroute\\Routes\\": "overrides/Axn/Laroute/Routes/",
"Webklex\\IMAP\\": "overrides/Webklex/IMAP/",
"RachidLaasri\\LaravelInstaller\\Helpers\\": "overrides/RachidLaasri/LaravelInstaller/Helpers/",
"RachidLaasri\\LaravelInstaller\\Middleware\\": "overrides/RachidLaasri/LaravelInstaller/Middleware/",
"RachidLaasri\\LaravelInstaller\\Controllers\\": "overrides/RachidLaasri/LaravelInstaller/Controllers/"
},
"exclude-from-classmap": [
"vendor/axn/laravel-laroute/src/Routes/Collection.php"
"vendor/axn/laravel-laroute/src/Routes/Collection.php",
"vendor/webklex/laravel-imap/src/IMAP/Message.php",
"vendor/rachidlaasri/laravel-installer/src/Helpers/PermissionsChecker.php",
"vendor/rachidlaasri/laravel-installer/src/Helpers/EnvironmentManager.php",
"vendor/rachidlaasri/laravel-installer/src/Helpers/FinalInstallManager.php",
"vendor/rachidlaasri/laravel-installer/src/Middleware/canInstall.php",
"vendor/rachidlaasri/laravel-installer/src/Controllers/EnvironmentController.php"
]
},
"autoload-dev": {
Expand Down
Loading

0 comments on commit d7f6090

Please sign in to comment.