I have this Controller:
class AdminLoginController extends Controller
{
public function index() {
return view('auth.admin.login');
}
}
route\web
Route::get('/admin/login', 'Auth\AdminLoginController@index')->name('admin.login');
I am using spatie
How do I do it that if the logged in user is not 'Super Admin'
> Auth::user()->hasRole('Super Admin')
The application should display Access Denied. But if its super admin, it should redirect to dashboard.
How can I get this done?
Thanks
Add new role in config/auth.php such as admin role.
Redefine redirect url in login controller for that role. (You can set it with Access Denied page)
Please add constructor in Dashboard controller as following
public function __construct() { $this->middleware('auth:super_admin'); }