This episode is for members only

Sign up to access "Social Authentication with Laravel" right now.

Get started
Already a member? Sign in to continue
Playing
12. Redirecting to the social authentication route

Transcript

00:00
So a very small update here, because we've created out a dedicated page, a new page for signing in, when we redirect if we're not authenticated, this is going to go over to the standard page to sign in. So as an example, if we try and access the dashboard when we're not logged in, this is going to redirect us over to the standard email and password flow.
00:20
So what we can do is very easily change this with the authenticate middleware. So let's go over to the authenticate middleware and app HTTP middleware. And as you can see, if the user is not signed in, we redirect to so all of the functionality of this is behind this base middleware, we redirect to login. Now, all we need to do to update this
00:42
is change this over to our own route, which we know if we just double check the name of it is auth and index. So let's change that to auth and index. And we're pretty much done. So now, if we are over on our homepage, and we try and access the dashboard, we're redirected over to our new page. And of course, we can click to sign in.

Episode summary

In this quick video, we make a small but important change to our authentication flow. Previously, when unauthenticated users tried to access protected pages (like the dashboard), they were always redirected to the default email and password login page. Now that we've set up a new, dedicated sign-in page (which supports social authentication), we need to make sure users land there instead.

We head into our authentication middleware—which handles redirection for unauthenticated users—and simply update the redirect route to our new sign-in page. After this tweak, whenever someone accesses a restricted page without being logged in, they're taken directly to our custom authentication page, offering a smoother, more integrated sign-in experience.

That's it for this episode—super quick, but it improves the flow for all users going forward!

Episode discussion

No comments, yet. Be the first!