Skip to content
This repository was archived by the owner on Nov 23, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ccbf8fb
Make it possible to switch guards
jorenvanhee Apr 28, 2017
a592571
Use correct guard in views
jorenvanhee May 2, 2017
2fd3f86
Fix order of use statements
jorenvanhee May 2, 2017
08b9390
Make the admin middleware use the backpack guard
jorenvanhee May 2, 2017
feac647
Merge branch 'different-user-model-issue-fix' of git://github.com/jor…
tabacitu Jul 6, 2017
87839c9
fixed lloyd's review objections in implementing custom auth guard
tabacitu Jul 6, 2017
0f992ac
Auth\Login: allow username customization
kichetof Feb 13, 2018
7c3593f
alert messages can now have html
tabacitu Feb 28, 2018
6fe7690
added sidebar_content file; publish minimum amount of files
tabacitu Feb 28, 2018
86bff8c
move dashboard sidebar item to sidebar_contents file
tabacitu Feb 28, 2018
d7518ec
added command that adds code to sidebar_content blade file
tabacitu Feb 28, 2018
df9680e
polished addSidebarContent definition and description
tabacitu Feb 28, 2018
aa4356a
Apply fixes from StyleCI
tabacitu Feb 28, 2018
62a20a3
changelog
tabacitu Feb 28, 2018
16b76a2
Merge branch 'publish-minimum-amount-of-files' of https://github.com/…
tabacitu Feb 28, 2018
b723665
fixes #253 - added command to add code to custom route file
tabacitu Feb 28, 2018
e0fdeca
Apply fixes from StyleCI
tabacitu Feb 28, 2018
afe6de3
fixed custom routes file namespace
tabacitu Feb 28, 2018
cf5d435
Merge branch 'custom-routes-file' of https://github.com/Laravel-Backp…
tabacitu Feb 28, 2018
2813799
merged master and fixed conflicts:
tabacitu Mar 5, 2018
37b49e1
cleaner config helper usage for guards and passwords
tabacitu Mar 5, 2018
107c1f3
cleaned up admin middleware
tabacitu Mar 5, 2018
a5a8015
fixed logout logging out all sessions; applied custom guard to MyAcco…
tabacitu Mar 5, 2018
2e1eea2
added backpack_auth helpers and removed view composers
tabacitu Mar 5, 2018
83758c6
Apply fixes from StyleCI
tabacitu Mar 5, 2018
edb3e52
cleanup
tabacitu Mar 5, 2018
5cd6190
comment method
tabacitu Mar 5, 2018
353d230
added BackpackUser model and made it the default user_model_fqn
tabacitu Mar 5, 2018
5b50727
Apply fixes from StyleCI
tabacitu Mar 5, 2018
42d556c
Merge branch 'master' of git://github.com/kichetof/Base into kichetof…
tabacitu Mar 6, 2018
9a28e97
merged PR #246, renamed variables and made necessary login view modif…
tabacitu Mar 6, 2018
ed41e9f
added authentication_column_name config variable
tabacitu Mar 6, 2018
b53c0a0
authentication_column_name should default to language email
tabacitu Mar 6, 2018
b9cf5c7
Apply fixes from StyleCI
tabacitu Mar 6, 2018
35778df
authentication_column should default to email
tabacitu Mar 6, 2018
13a9de5
Merge branch 'allow-login-with-username' of https://github.com/Larave…
tabacitu Mar 6, 2018
880e770
Apply fixes from StyleCI
tabacitu Mar 6, 2018
f05430b
ability to customize admin middleware; fixes #67
tabacitu Mar 6, 2018
4d4bd8c
Apply fixes from StyleCI
tabacitu Mar 6, 2018
fc3a907
renamed Admin middleware class to CheckIfAdmin
tabacitu Mar 6, 2018
9d1649c
Merge branch 'custom-admin-middleware' of https://github.com/Laravel-…
tabacitu Mar 6, 2018
cb3b056
changed middleware to a middleware group, so that developers can incl…
tabacitu Mar 6, 2018
e485098
Apply fixes from StyleCI
tabacitu Mar 6, 2018
06bf447
cleaned up BaseServiceProvider
tabacitu Mar 6, 2018
52b895c
Merge branch 'custom-admin-middleware' of https://github.com/Laravel-…
tabacitu Mar 6, 2018
459d575
Apply fixes from StyleCI
tabacitu Mar 6, 2018
4ca7a19
register with username instead of email
tabacitu Mar 7, 2018
3ca67c4
fixed registration, my account and password reset when using username…
tabacitu Mar 7, 2018
33a9053
Merge branch 'allow-login-with-username' of https://github.com/Larave…
tabacitu Mar 7, 2018
1f82ace
Apply fixes from StyleCI
tabacitu Mar 7, 2018
d6ebf8d
improved backpack_avatar_url helper
tabacitu Mar 7, 2018
769abae
merged
tabacitu Mar 7, 2018
caa2cef
fixed review issues
tabacitu Mar 8, 2018
b153b4e
translated reset password email
tabacitu Mar 8, 2018
bb99618
Merge branch 'jorenvanhee-different-user-model-issue-fix' of https://…
tabacitu Mar 8, 2018
e6ac6e8
Apply fixes from StyleCI
tabacitu Mar 8, 2018
1952f3e
Merge branch 'jorenvanhee-different-user-model-issue-fix' into upgrade
tabacitu Mar 8, 2018
49e63e3
Merge branch 'upgrade' of https://github.com/Laravel-Backpack/Base in…
tabacitu Mar 8, 2018
6651a22
typo
tabacitu Mar 8, 2018
42a8c0a
Merge branch 'publish-minimum-amount-of-files' into upgrade
tabacitu Mar 8, 2018
8822a6a
Merge remote-tracking branch 'origin/custom-routes-file' into upgrade
tabacitu Mar 8, 2018
5c723cb
using helper to get backpack middleware in custom routes file
tabacitu Mar 8, 2018
e58ac9f
Merge branch 'html-alerts' into upgrade
tabacitu Mar 8, 2018
8fe173b
added license checks
tabacitu Mar 8, 2018
a959ebb
Apply fixes from StyleCI
tabacitu Mar 8, 2018
833091c
added stacks after sections in layout
tabacitu Mar 8, 2018
7da688d
cleanup
tabacitu Mar 8, 2018
f110170
changelog
tabacitu Mar 8, 2018
069aa50
Merge branch 'feature-stacks' into upgrade
tabacitu Mar 8, 2018
71a7ee7
changelog
tabacitu Mar 8, 2018
22b4427
Merge branch 'allow-login-with-username' into upgrade
tabacitu Mar 8, 2018
97bd1bf
cleanup
tabacitu Mar 8, 2018
6a235cb
Merge branch 'upgrade' of https://github.com/Laravel-Backpack/Base in…
tabacitu Mar 8, 2018
095418e
updated js dependencies to match new adminlte paths
tabacitu Mar 8, 2018
e69a3d5
license check takes into acount config file variable
tabacitu Mar 9, 2018
4825256
made root disk name configurable
tabacitu Mar 5, 2018
ce3c074
Apply fixes from StyleCI
tabacitu Mar 13, 2018
03241e9
Merge branch 'master' into upgrade
tabacitu Mar 22, 2018
5d68bfa
composer require updated adminlte
tabacitu Mar 22, 2018
5606018
Merge branch 'upgrade' into adminlte-update
tabacitu Mar 8, 2018
e6e8ece
Merge branch 'custom-admin-middleware' of https://github.com/Laravel-…
tabacitu Mar 22, 2018
2cbce1f
Update custom.php
tabacitu Mar 22, 2018
1a04f2c
Merge pull request #264 from Laravel-Backpack/adminlte-update
tabacitu Mar 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
### Security
- Nothing

-------

### Added
- flexbox css helper class;
- support for HTML messages inside Alert bubbles, when triggered from PHP;
- added publish lang command;
- added command to publish only the minimum amount of files needed for Backpack to work;
- ```sidebar_content.blade.php``` file, so that we can add sidebar items using a command
- ```php artisan backpack:base:add-sidebar-content``` command;
- ```php artisan backpack:base:add-custom-route``` command;

### Fixed
- the installation command now only publishes the minimum amount of files, by default;

## [0.8.9] - 2018-02-08

Expand Down
113 changes: 93 additions & 20 deletions src/BaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class BaseServiceProvider extends ServiceProvider
{
protected $commands = [
\Backpack\Base\app\Console\Commands\Install::class,
\Backpack\Base\app\Console\Commands\AddSidebarContent::class,
\Backpack\Base\app\Console\Commands\AddCustomRouteContent::class,
];

/**
Expand All @@ -26,6 +28,13 @@ class BaseServiceProvider extends ServiceProvider
*/
public $routeFilePath = '/routes/backpack/base.php';

/**
* Where custom routes can be written, and will be registered by Backpack.
*
* @var string
*/
public $customRoutesFilePath = '/routes/backpack/custom.php';

/**
* Perform post-registration booting of services.
*
Expand All @@ -46,8 +55,15 @@ public function boot(\Illuminate\Routing\Router $router)
__DIR__.'/config/backpack/base.php', 'backpack.base'
);

$this->registerAdminMiddleware($this->app->router);
// add the root disk to filesystem configuration
app()->config['filesystems.disks.root'] = [
'driver' => 'local',
'root' => base_path(),
];

$this->registerMiddlewareGroup($this->app->router);
$this->setupRoutes($this->app->router);
$this->setupCustomRoutes($this->app->router);
$this->publishFiles();
$this->loadHelpers();
}
Expand Down Expand Up @@ -80,6 +96,21 @@ public function setupRoutes(Router $router)
$this->loadRoutesFrom($routeFilePathInUse);
}

/**
* Load custom routes file.
*
* @param \Illuminate\Routing\Router $router
*
* @return void
*/
public function setupCustomRoutes(Router $router)
{
// if the custom routes file is published, register its routes
if (file_exists(base_path().$this->customRoutesFilePath)) {
$this->loadRoutesFrom(base_path().$this->customRoutesFilePath);
}
}

/**
* Register any package services.
*
Expand Down Expand Up @@ -111,41 +142,83 @@ public function register()
if (class_exists('Backpack\Generators\GeneratorsServiceProvider')) {
$this->app->register('Backpack\Generators\GeneratorsServiceProvider');
}
} else {
$this->checkLicenseCodeExists();
}

// register the artisan commands
$this->commands($this->commands);
}

public function registerAdminMiddleware(Router $router)
public function registerMiddlewareGroup(Router $router)
{
Route::aliasMiddleware('admin', \Backpack\Base\app\Http\Middleware\Admin::class);
}
$middleware_key = config('backpack.base.middleware_key');
$middleware_class = config('backpack.base.middleware_class');

public function publishFiles()
{
// publish config file
$this->publishes([__DIR__.'/config' => config_path()], 'config');
if (!is_array($middleware_class)) {
$router->pushMiddlewareToGroup($middleware_key, $middleware_class);

// publish lang files
// $this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang');
return;
}

// publish views
$this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/base')], 'views');
foreach ($middleware_class as $middleware_class) {
$router->pushMiddlewareToGroup($middleware_key, $middleware_class);
}
}

// publish error views
$this->publishes([__DIR__.'/resources/error_views' => resource_path('views/errors')], 'errors');
public function publishFiles()
{
$error_views = [__DIR__.'/resources/error_views' => resource_path('views/errors')];
$backpack_base_views = [__DIR__.'/resources/views' => resource_path('views/vendor/backpack/base')];
$backpack_public_assets = [__DIR__.'/public' => public_path('vendor/backpack')];
$backpack_lang_files = [__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')];
$backpack_config_files = [__DIR__.'/config' => config_path()];

// publish public Backpack assets
$this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public');
// sidebar_content view, which is the only view most people need to overwrite
$backpack_sidebar_contents_view = [__DIR__.'/resources/views/inc/sidebar_content.blade.php' => resource_path('views/vendor/backpack/base/inc/sidebar_content.blade.php')];
$backpack_custom_routes_file = [__DIR__.$this->customRoutesFilePath => base_path($this->customRoutesFilePath)];

// calculate the path from current directory to get the vendor path
$vendorPath = dirname(__DIR__, 3);
$adminlte_assets = [$vendorPath.'/almasaeed2010/adminlte' => public_path('vendor/adminlte')];
$gravatar_assets = [$vendorPath.'/creativeorange/gravatar/config' => config_path()];

// establish the minimum amount of files that need to be published, for Backpack to work; there are the files that will be published by the install command
$minimum = array_merge(
$error_views,
// $backpack_base_views,
$backpack_public_assets,
// $backpack_lang_files,
$backpack_config_files,
$backpack_sidebar_contents_view,
$backpack_custom_routes_file,
$adminlte_assets,
$gravatar_assets
);

// publish public AdminLTE assets
$this->publishes([$vendorPath.'/almasaeed2010/adminlte' => public_path('vendor/adminlte')], 'adminlte');
// register all possible publish commands and assign tags to each
$this->publishes($backpack_config_files, 'config');
$this->publishes($backpack_lang_files, 'lang');
$this->publishes($backpack_base_views, 'views');
$this->publishes($backpack_sidebar_contents_view, 'sidebar_content');
$this->publishes($error_views, 'errors');
$this->publishes($backpack_public_assets, 'public');
$this->publishes($backpack_custom_routes_file, 'custom_routes');
$this->publishes($adminlte_assets, 'adminlte');
$this->publishes($gravatar_assets, 'gravatar');
$this->publishes($minimum, 'minimum');
}

// publish public Gravatar assets
$this->publishes([$vendorPath.'/creativeorange/gravatar/config' => config_path()], 'gravatar');
/**
* Check to to see if a license code exists.
* If it does not, throw a notification bubble.
*
* @return void
*/
private function checkLicenseCodeExists()
{
if (! env('BACKPACK_LICENSE')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be in a config?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Totally! Done, thank you!

\Alert::add('warning', "<strong>You're using unlicensed software.</strong> Please ask your web developer to <a target='_blank' href='http://backpackforlaravel.com'>purchase a license code</a> to hide this message.");
}
}
}
84 changes: 84 additions & 0 deletions src/app/Console/Commands/AddCustomRouteContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

namespace Backpack\Base\app\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

class AddCustomRouteContent extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:base:add-custom-route
{code : HTML/PHP code that registers a route. Use either single quotes or double quotes. Never both. }';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Add HTML/PHP code to the routes/backpack/custom.php file';

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

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = 'routes/backpack/custom.php';
$disk = Storage::disk('root');
$code = $this->argument('code');

if ($disk->exists($path)) {
$old_file_content = Storage::disk('root')->get($path);

// insert the given code before the file's last line
$file_lines = explode(PHP_EOL, $old_file_content);
$number_of_lines = count($file_lines);
$file_lines[$number_of_lines] = $file_lines[$number_of_lines - 1];
$file_lines[$number_of_lines - 1] = ' '.$code;
$new_file_content = implode(PHP_EOL, $file_lines);

if ($disk->put($path, $new_file_content)) {
$this->info('Successfully added code to '.$path);
} else {
$this->error('Could not write to file: '.$path);
}
} else {
$command = 'php artisan vendor:publish --provider="Backpack\Base\BaseServiceProvider" --tag=custom_routes';

$process = new Process($command, null, null, null, 300, null);

$process->run(function ($type, $buffer) {
if (Process::ERR === $type) {
$this->line($buffer);
} else {
$this->line($buffer);
}
});

// executes after the command finishes
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}

$this->handle();
}
}
}
58 changes: 58 additions & 0 deletions src/app/Console/Commands/AddSidebarContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Backpack\Base\app\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;

class AddSidebarContent extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:base:add-sidebar-content
{code : HTML/PHP code that shows the sidebar item. Use either single quotes or double quotes. Never both. }';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Add HTML/PHP code to the Backpack sidebar_content file';

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

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = 'resources/views/vendor/backpack/base/inc/sidebar_content.blade.php';
$disk = Storage::disk('root');
$code = $this->argument('code');

if ($disk->exists($path)) {
$contents = Storage::disk('root')->get($path);

if ($disk->put($path, $contents.PHP_EOL.$code)) {
$this->info('Successfully added code to sidebar_content file.');
} else {
$this->error('Could not write to sidebar_content file.');
}
} else {
$this->error("The sidebar_content file does not exist. Make sure Backpack\Base is properly installed.");
}
}
}
2 changes: 1 addition & 1 deletion src/app/Console/Commands/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function handle()
$this->executeProcess('composer require laracasts/generators:dev-master --dev');

$this->line(' Publishing configs, langs, views and AdminLTE files');
$this->executeProcess('php artisan vendor:publish --provider="Backpack\Base\BaseServiceProvider"');
$this->executeProcess('php artisan vendor:publish --provider="Backpack\Base\BaseServiceProvider" --tag=minimum');

$this->line(' Publishing config for notifications - prologue/alerts');
$this->executeProcess('php artisan vendor:publish --provider="Prologue\Alerts\AlertsServiceProvider"');
Expand Down
4 changes: 2 additions & 2 deletions src/app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AdminController extends Controller
*/
public function __construct()
{
$this->middleware('admin');
$this->middleware(backpack_middleware());
}

/**
Expand All @@ -34,6 +34,6 @@ public function dashboard()
public function redirect()
{
// The '/admin' route is not to be used as a page, because it breaks the menu's active state.
return redirect(config('backpack.base.route_prefix').'/dashboard');
return redirect(backpack_url('dashboard'));
}
}
17 changes: 16 additions & 1 deletion src/app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Backpack\Base\app\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;

class ForgotPasswordController extends Controller
{
Expand All @@ -29,7 +30,9 @@ class ForgotPasswordController extends Controller
*/
public function __construct()
{
$this->middleware('guest');
$guard = backpack_guard_name();

$this->middleware("guest:$guard");
}

// -------------------------------------------------------
Expand All @@ -47,4 +50,16 @@ public function showLinkRequestForm()

return view('backpack::auth.passwords.email', $this->data);
}

/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
$passwords = config('backpack.base.passwords', config('auth.defaults.passwords'));

return Password::broker($passwords);
}
}
Loading