Apps (Coming Soon) 10 / 32
Laravel Jetstream
Learn how to install DevDojo Auth with the Jetstream starter kit.
In this installation page we'll show you the steps to install Auth within a new Jetstream application.
Create a new Jetstream application
If you are using the Laravel installer, you may be prompted to install a starter kit. In this prompt you can select Laravel Jetstream to install the Jetstream starter kit. Alternatively, if you're in a new Laravel app you can install Jetstream by following the installation steps here.
Install the Auth Package
After you've created a new Jetstream app you'll want to require the auth package:
composer require devdojo/auth
Next, you'll need to publish the assets, configs, CI workflow, and migrations:
php artisan vendor:publish --tag=auth:assets
php artisan vendor:publish --tag=auth:config
php artisan vendor:publish --tag=auth:ci
php artisan vendor:publish --tag=auth:migrations
Next, you'll want to run the new migrations:
php artisan migrate
Finally, you need to extend the DevDojo User model from App\Models\User.php:
use Devdojo\Auth\Models\User as AuthUser;
class User extends AuthUser
Now that we have DevDojo Auth set up, there are a handful of things that we need to update.
Publish the Fortify config
Jetstream utilizes Fortify under the hood, so we need to publish the Fortify config and make a few changes:
php artisan vendor:publish --tag=fortify-config
Inside of this config, located at config/fortify.php, you'll need to set views to false, like so:
'views' => false,
and you'll also need to comment out the registration, resetPassword, emailVerification, and twoFactorAuth features since we will be relying on DevDojo Auth for this functionality:
'features' => [
//Features::registration(),
//Features::resetPasswords(),
// Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
// Features::twoFactorAuthentication([
// 'confirm' => true,
// 'confirmPassword' => true,
// // 'window' => 0,
// ]),
],
Enable the Name Field for Registration
As Jetstream depends on the name field for registration, you'll want to enable this option in the setup page.
You can do that by visiting the /auth/setup route, clicking on Settings, and enabling the Registration Include Name Field option.
Modify Inertia Links
Note: Only applicable when using an Inertia stack.
By default your application's Welcome.vue file, located inside of resources/js/Pages/Welcome.*, will have the following component links using the Link component:
<Link
:href="route('login')"
class="..."
>
Log in
</Link>
<Link
v-if="canRegister"
:href="route('register')"
class="..."
>
Register
</Link>
You will need to replace these Link elements with an a element, so that it looks like this instead:
<a
:href="route('login')"
class="..."
>
Log in
</a>
<a
v-if="canRegister"
:href="route('register')"
class="..."
>
Register
</a>
This is because when the application uses the Link element, Inertia will open these links via XHR requests, but we need them to perform their own request and function like normal links (traditional a tags).
Conditionally Enable 2FA
If you want to enable two-factor authentication on your site you can do that by visiting /auth/setup and clicking on the Settings section. Then toggle the Enable 2FA option and your users will now see the ability to enable two-factor authentication from their edit profile page.
That's it! DevDojo Auth is now working with Jetstream. You can enable 2FA in the Auth settings page and it will enable/disable 2FA and work with the current Jetstream implementation.