Reputation: 359
After reading some tutorials on laravel 5.4 authentication (including the doc),I don't know how to work with it in my file. I have been able to run the artisan command.. php artisan make:auth. Have seen the the controller, views etc that was created and even have accessed it by going to http://localhost/blogsite/public/register (don't worry about, its on my local disk) but how do I integrate it with with the pages that needs authentication? That I don't know..
Who can put me through how to integrate it with other pages
Upvotes: 0
Views: 69
Reputation: 1635
Many way you can use for this solution.
First Way:
If you load views file from controller just use the following line to your controller.
Suppose my controller name is DashBoardController
public function __construct()
{
$this->middleware('auth');
}
So all of the view
you return from DashboardController
it will make you auth
for you. That means if you return any of view
from this controller
you must need to log in.
So you need to put this constructor function to all of your Controller
from where you return view
and need to authenticate the user.
To avoid this constructor funtion to all controller you can use the following
Way using route
:
Route::group(['middleware' => 'auth'], function () {
Route::Your_Request_Method('your_url1', 'YourController1');
Route::Your_Request_Method('your_url2', 'YourController2');
});
You can get more way at laravel authentication documentation
Hope you will understand.
Upvotes: 0