Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

php - how can I make middlware to control the no one go to page without id ln Laravel 7 project

I have LMS project and and have 3 role admin, teacher, student I can't make middleware to control no one access to admin or teacher or student except

It is a Laravel 7 project.

question from:https://stackoverflow.com/questions/65848949/how-can-i-make-middlware-to-control-the-no-one-go-to-page-without-id-ln-laravel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So you probably want to ensure, that everyone is properly authenticated and logged in.

In you routes file you should run all routes where only authenticated user should have access through the auth middlware.

Route::group(['middleware' => ['auth']], function() {
    Route::get('/home', 'HomeController@index')->name('home');
    // more routes
});

To specify where the user should be redirected to you can open the middleware at app/Http/Middlware/Authentication.php and check the method

protected function redirectTo($request)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...