Skip to content

Commit

Permalink
allow user to logout even dont have permission to viewNova
Browse files Browse the repository at this point in the history
  • Loading branch information
anditsung committed Jul 10, 2020
1 parent d9ee541 commit 35013e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Http/Middleware/NovauserAuthorize.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
namespace Tsung\NovaUserManagement\Http\Middleware;


use Illuminate\Http\Request;
use Laravel\Nova\Nova;
use Spatie\Permission\PermissionRegistrar;

class NovauserAuthorize
{
public function handle($request, $next)
public function handle(Request $request, $next)
{
if(Nova::check($request)) {

Expand All @@ -20,6 +21,12 @@ public function handle($request, $next)
return $next($request);
}
else {
// allow user to logout if dont have viewNova permission
if ($request->getPathInfo() == '/nova/logout') {

return $next($request);

}
// if the user dont have viewNova permissions then redirect to '/'
// return abort(403);
return redirect('/');
Expand Down

0 comments on commit 35013e6

Please sign in to comment.