Skip to content

Commit

Permalink
Merge pull request #4 from ARCANEDEV/develop
Browse files Browse the repository at this point in the history
Updating the package for Laravel 5.5
  • Loading branch information
arcanedev-maroc authored Aug 31, 2017
2 parents b4cecf7 + 399f587 commit ff6e8f3
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 2
php_code_sniffer:
enabled: true
config:
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1
- nightly
Expand All @@ -13,7 +12,7 @@ matrix:
- php: nightly

env:
- TESTBENCH_VERSION=3.4.*
- TESTBENCH_VERSION=3.5.*

before_script:
- travis_retry composer self-update
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelImpers

### Features

* Laravel `5.4` is supported.
* Laravel `5.4 | 5.5` are supported.
* Easy setup & configuration.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
Expand All @@ -32,7 +32,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelImpers

## TODO

- [ ] Adding Laravel `5.1 | 5.2 | 5.3` Support.
- [ ] Adding Laravel `5.1 | 5.2 | 5.3` Support ?
- [ ] Adding Blade directives.
- [ ] Complete the model factories.
- [ ] Complete the documentation.
Expand All @@ -51,7 +51,7 @@ Any ideas are welcome. Feel free to submit any issues or pull requests, please c
- [All Contributors][link-contributors]

[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-impersonator.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.4-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-5.4%20to%205.5-orange.svg?style=flat-square
[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelImpersonator.svg?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelImpersonator.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/LaravelImpersonator.svg?style=flat-square
Expand Down
Empty file added _docs/0-Home.md
Empty file.
Empty file.
Empty file added _docs/2-Configuration.md
Empty file.
Empty file added _docs/3-Usage.md
Empty file.
21 changes: 12 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"type": "library",
"license": "MIT",
"require": {
"php": ">=5.6",
"php": ">=7.0",
"arcanedev/support": "~4.0",
"arcanesoft/contracts": "~2.0.0"
"arcanesoft/contracts": "~2.0"
},
"require-dev": {
"phpunit/phpcov": "~3.0",
"phpunit/phpunit": "~5.0"
"phpunit/phpcov": "~4.0",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -39,10 +39,13 @@
"testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.0\" \"orchestra/database=~3.0\""
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"laravel": {
"providers": [
"Arcanedev\\LaravelImpersonator\\ImpersonatorServiceProvider"
],
"aliases": {
"Impersonator": "Arcanedev\\LaravelImpersonator\\Facades\\Impersonator"
}
}
},
"minimum-stability": "dev",
"prefer-stable" : true
}
}
5 changes: 1 addition & 4 deletions src/Events/ImpersonationStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
* @package Arcanedev\LaravelImpersonator\Events
* @author ARCANEDEV <[email protected]>
*/
class ImpersonationStarted extends AbstractImpersonationEvent
{
//
}
class ImpersonationStarted extends AbstractImpersonationEvent {}
5 changes: 1 addition & 4 deletions src/Events/ImpersonationStopped.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
* @package Arcanedev\LaravelImpersonator\Events
* @author ARCANEDEV <[email protected]>
*/
class ImpersonationStopped extends AbstractImpersonationEvent
{
//
}
class ImpersonationStopped extends AbstractImpersonationEvent {}
5 changes: 1 addition & 4 deletions src/Exceptions/ImpersonationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@
* @package Arcanedev\LaravelImpersonator\Exceptions
* @author ARCANEDEV <[email protected]>
*/
class ImpersonationException extends \Exception
{
//
}
class ImpersonationException extends \Exception {}
7 changes: 3 additions & 4 deletions src/Http/Middleware/ImpersonationNotAllowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public function __construct(Impersonator $impersonator)
*/
public function handle($request, Closure $next)
{
if ($this->impersonator->isImpersonating())
return redirect()->back();

return $next($request);
return $this->impersonator->isImpersonating()
? redirect()->back()
: $next($request);
}
}
24 changes: 11 additions & 13 deletions src/ImpersonatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,17 @@ private function extendAuthDriver()

$this->app['auth']->extend('session', function (Application $app, $name, array $config) use ($auth) {
$provider = $auth->createUserProvider($config['provider']);
$guard = new Guard\SessionGuard($name, $provider, $app['session.store']);

if (method_exists($guard, 'setCookieJar')) {
$guard->setCookieJar($app['cookie']);
}
if (method_exists($guard, 'setDispatcher')) {
$guard->setDispatcher($app['events']);
}
if (method_exists($guard, 'setRequest')) {
$guard->setRequest($app->refresh('request', $guard, 'setRequest'));
}

return $guard;

return tap(new Guard\SessionGuard($name, $provider, $app['session.store']), function ($guard) use ($app) {
if (method_exists($guard, 'setCookieJar'))
$guard->setCookieJar($app['cookie']);

if (method_exists($guard, 'setDispatcher'))
$guard->setDispatcher($app['events']);

if (method_exists($guard, 'setRequest'))
$guard->setRequest($app->refresh('request', $guard, 'setRequest'));
});
});
}
}

0 comments on commit ff6e8f3

Please sign in to comment.