reziamini / laravel-easypanel

A beautiful and flexible admin panel creator based on Livewire for Laravel
https://easypanel.netlify.app/getting-started
MIT License
619 stars 105 forks source link

Better behavior if you route to admin before login #16

Closed Mokei-it closed 3 years ago

Mokei-it commented 3 years ago

Hello,

if you try to go directly to http://localhost:8000/admin before login, you get an ErrorException.

To get a better answer from server what do you think to modify \vendor\rezaamini-ir\laravel-easypanel\src\Http\Middleware\isAdmin.php

from `

    public function handle($request, Closure $next)
    {
        if(!AuthFacade::checkIsAdmin(auth()->user()->id)){
                return redirect(config('easy_panel.redirect_unauthorized'));
        }
        return $next($request);
    }

`

to `

    public function handle($request, Closure $next)
    {
        if(!Auth::check()) {
            return redirect('login');
        }else{
            if(!AuthFacade::checkIsAdmin(auth()->user()->id)){
                return redirect(config('easy_panel.redirect_unauthorized'));
            }
        }
        return $next($request);
    }

` Thank you!

reziamini commented 3 years ago

Thanks to share your idea. I will take a look and make a decision for this part of project