Skip to content

Commit

Permalink
Unauthorized url redirect configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
acoustep committed Mar 3, 2016
1 parent 6f0f990 commit 12c1940
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Add user name field to users form


## [0.6.0] - 2016-03-03
### Changed
- Config option for changing unauthorized redirects

## [0.5.0] - 2015-09-13
### Changed
- Console command for generating model files
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ class Permission extends EntrustPermission implements ValidatingModelInterface
```
## Upgrade Guide / Breaking Changes

### 0.6

Includes a new config key, "unauthorized-url" which lets you set the redirection if a user is not authorized. If this key is not found, it will use the old url, /auth/login. The default is set to /auth/login to match Laravel 5.1's documentation on the [authentication routes](https://www.laravel.com/docs/5.1/authentication#included-routing).

### 0.3.* to 0.4.0

Starting from 0.4.0 Entrust GUI switches from ```dwightwatson/validating``` to ```esensi/model```.
Expand Down
1 change: 1 addition & 0 deletions config/entrust-gui.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"permissions" => 5,
],
"middleware" => 'entrust-gui.admin',
"unauthorized-url" => '/login',
"middleware-role" => 'admin',
"confirmable" => false,
];
2 changes: 1 addition & 1 deletion src/Http/Middleware/AdminAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle($request, Closure $next)
if ($request->ajax()) {
return $this->response->make('Unauthorized.', 401);
} else {
return $this->redirect->guest('auth/login');
return $this->redirect->guest($this->config->get('entrust-gui.unauthorized-url', 'auth/login'));
}
} elseif (! $request->user()->hasRole($this->config->get('entrust-gui.middleware-role'))) {
return $this->response->make('Unauthorized.', 401); //Or redirect() or whatever you want
Expand Down

0 comments on commit 12c1940

Please sign in to comment.