This episode is for members only

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

Get started
Already a member? Sign in to continue
Playing
08. Sending the magic login link again

Transcript

00:00
Once we've registered the user within this action by calling handle from asController, down here we want to send that email so they can actually sign in. Of course, we don't need to
00:10
because they can head over to the login page to request one. But when we're registering, we expect to have a more convenient way to sign in. Now, how do we do this? Well, what we can actually do is inject in the SendMagicLink action that we previously created for our login process inside of here. So, we can pull that in and then we can just invoke it from in here by calling the
00:32
handle method. Now, we know that handle gives us back the user that we've just created. So, what we can do is assign this user. Now, we have an instance of that user that's been created and we can go ahead and invoke or handle the SendMagicLink action. Now, that requires, if we remember, an email address to be passed in. We have that user now, so we can just pass in
00:57
the email address in there and that should trigger that action to send an email. And remember, this SendMagicLink is not triggering the controller part of this. It's triggering just the handle method of this, which is just responsible for one thing and that is sending the email. Okay, let's try this out. So, I'm going to go ahead and register mabel at codecourse.com
01:19
again and let's go ahead and enter the name. Hit register and we should have a magic login link sent to Mabel. Hit login and there we go. We are signed in. Easy as that. We'd already created the action that is responsible for sending the email or anything else we need to do. So, we've just reused that within the registration process really conveniently to perform that same action.
10 episodes 58 mins

Overview

Say goodbye to the traditional email/password flow and implement passwordless authentication with Laravel! In this course, we'll cover sending a secure link via email to allow users to sign in seamlessly. Oh, and we'll cover the entire registration process too.

Use it on its own, or combine it with the standard email/password flow to give your users even more flexibility.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.