This episode is for members only

Sign up to access "Authentication with Laravel Sanctum and Vue" right now.

Get started
Already a member? Sign in to continue
Playing
05. Installing Fortify

Transcript

00:00
Laravel Fortify is a front-end agnostic authentication package for Laravel. Once we get this installed, this is going to provide to us a bunch of controllers and functionality that will allow us to do things like register an account, log in, log out, and also more advanced things like two-factor authentication. So we're going to go ahead and get this installed.
00:23
We're going to have a look around how this changes our app so we can really understand how this works and then we're going to use our client to hit the routes that Fortify registers for us. Okay let's go ahead and get this installed. So we're going to go ahead and pull this package in first of all. Once that's done we can go ahead and issue the install command which is going to do a
00:46
few things within our application. So we can see that the Fortify scaffolding has been installed successfully. Let's go ahead and just migrate our database with anything that this provides to us and then we'll go ahead and look around our app and we'll see what's changed. Okay so you can see that that migration added some two-factor columns to our table and we can use that later if we need
01:07
to but let's just take a look around the structure of our app and see what is different. Okay so the first thing you'll notice in app you'll have this actions directory. What's happening here is this will register a bunch of single class things that just do one job. For example if you wanted to customize how a user is created when you hit the register endpoint you can go ahead and update this
01:30
to pretty much add any validation rules you want and you can also customize what happens when the user gets created. We also have things like when the password is updated or the profile information is updated and we're not really going to be touching these but they're there for you to customize later if you need to. Now what you'll also notice is that when you run php artisan
01:52
root and list this will list out a bunch more routes than we had when we hadn't installed fortify. So you can see here that we've got a login route registered a register route registered and a bunch of other stuff as well. So you can see that these are provided from the fortify package so these aren't directly controllable by us but all of this functionality is customizable and when
02:15
you finish the course if you need to change anything around about this for example what response is given you can go ahead and customize pretty much anything you need to. Now like I said earlier these are registered as web routes that is why over in our course config we went ahead and updated these urls just here. These aren't registered as part of our api because they're
02:39
just registered in that location for both web and api routes. So if we were to hit this login route without this being registered here under our course configuration it would give us back a course error. After you're done with the course if you're adding any more functionality onto your client side and you're making use of any other routes that are registered with fortify you'll
03:00
want to go ahead and add them in here as well. Okay so fortify is now installed just one thing I'm going to do is head over to the web routes and I'm going to get rid of this main route here since we're just working with an api and that's pretty much it. We now have some really powerful authentication functionality powered by laravel fortify that we can start to hit from the client side.
21 episodes1 hr 35 mins

Overview

Learn how to authenticate with a Laravel API from Vue using the Composition API.

We'll start by setting up a fresh Laravel project with Sanctum and Fortify, configure everything step-by-step, and then implement the ability to authenticate from Vue with a simple auth module — thanks to the flexibility of the Composition API.

In the second half of the course, we’ll create our own beautiful starter kit with more features, including registration and middleware to protect routes.

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

Comments

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