25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Post-login redirection<br />

When a user logs in, <strong>Laravel</strong> will redirect them to a page defined by the<br />

$redirectTo attribute in the login controller. Let's change this from /home to /.<br />

app/Http/Auth/Controllers/LoginController.php: class LoginController extends<br />

Controller { ... protected $redirectTo = '/'; ... }<br />

Let's also update the RedirectIfAuthenticated middleware class so that if a logged-in<br />

user attempts to view the login page, they're redirect to / (instead of the default<br />

/home value.) app/Http/Middleware/RedirectIfAuthenticated.php: ... if<br />

(Auth::guard($guard)->check()) { return redirect('/'); }<br />

With that done, our login process will now work correctly.

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

Saved successfully!

Ooh no, something went wrong!