/fortify-ui

Laravel Fortify driven replacement to the Laravel UI package

Primary LanguageBladeMIT LicenseMIT

Introduction

FortifyUI is an unopinionated authentication starter, powered by Laravel Fortify. This package can be used to start your project, or you can use the FortifyUI Preset Template to create your own preset to install with FortifyUI. It is completely unstyled -- on purpose -- and only includes a minimal amount of markup to get your project running quickly.

Installation

To get started, you'll need to install FortifyUI using Composer. This will install Laravel Fortify as well so, please make sure you do not have it installed, already.

composer require zacksmash/fortify-ui

Next, you'll need to run the install command:

php artisan fortify-ui:install

This command will publish FortifyUI's views, add the home route to web.php and add the FortifyUI service provider to your app/Providers directory.

That's it, you're all setup! For advanced setup and configuration options, keep reading!

Configuration

If you'd rather not include the service provider file, you can skip generating it by using the --skip-provider flag.

php artisan fortify-ui:install --skip-provider

Then, you can add this to your AppServiceProvider or FortifyServiceProvider, in the boot() method.

Fortify::loginView(function () {
    return view('auth.login');
});

Fortify::registerView(function () {
    return view('auth.register');
});

Fortify::requestPasswordResetLinkView(function () {
    return view('auth.forgot-password');
});

Fortify::resetPasswordView(function ($request) {
    return view('auth.reset-password', ['request' => $request]);
});

// Fortify::verifyEmailView(function () {
//     return view('auth.verify-email');
// });

// Fortify::confirmPasswordView(function () {
//     return view('auth.confirm-password');
// });

// Fortify::twoFactorChallengeView(function () {
//     return view('auth.two-factor-challenge');
// });

To register all views at once, you can use this instead:

Fortify::viewPrefix('auth.');

Now, you should have all of the registered routes and views required by Laravel Fortify, including basic layout and home views, as well as optional password confirmation and email verification views.

Features

By default, FortifyUI is setup to handle the basic authentication functions (Login, Register, Password Reset) provided by Laravel Fortify.

Email Verification

To enable the email verification feature, you'll need to visit the FortifyUI service provider and uncomment Fortify::verifyEmailView(), to register the view. Next, you'll need to follow the instructions from Laravel Fortify's documentation to update your User model and the fortify.php config file. This allows you to attach the verified middleware to any of your routes, which is handled by the verify.blade.php file.

Password Confirmation

To enable the password confirmation feature, you'll need to visit the FortifyUI service provider and uncomment Fortify::confirmPasswordView(), to register the view. This allows you to attach the password.confirm middleware to any of your routes, which is handled by the password-confirm.blade.php file.

Two-Factor Authentication

To enable the two-factor authentication feature, you'll need to visit the FortifyUI service provider and uncomment Fortify::twoFactorChallengeView(), to register the view. Then, go to the fortify.php config file and make sure Features::twoFactorAuthentication is uncommented. Next, you'll want to update your User model to include the following:

use Laravel\Fortify\TwoFactorAuthenticatable;

class User extends Authenticatable
{
    use HasFactory, Notifiable, TwoFactorAuthenticatable;
    ...

That's it! Now, you can log into your application and enable or disable two-factor authentication.

Update User Password/Profile

To enable the ability to update user passwords and/or profile information, go to the fortify.php config file and make sure these features are uncommented:

Features::updateProfileInformation(),
Features::updatePasswords(),

FortifyUI Presets

FortifyUI encourges make your own presets, with your favorite frontend libraries and frameworks. To give you an idea of what that looks like, please take a look at FortifyUIkit and use the FortifyUI Preset Template to create your own.

License

FortifyUI is open-sourced software licensed under the MIT license.