25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Protecting the saved route<br />

We can use our login system now to protect certain routes from guests, that is,<br />

unauthenticated users. <strong>Laravel</strong> provides the auth middleware, which can be<br />

applied to any route <strong>and</strong> will redirect a guest user to the login page if they<br />

attempt to access it. Let's apply this to our saved page route.<br />

routes/web.php: Route::get('/saved', 'ListingController@get_home_web')-<br />

>middleware('auth');<br />

If you log out of the application <strong>and</strong> attempt to access this route from the<br />

navigation bar of your browser, you'll find it redirects you back to /login.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!