Giter Site home page Giter Site logo

zacksmash / fortify-ui Goto Github PK

View Code? Open in Web Editor NEW
238.0 8.0 20.0 118 KB

Laravel Fortify driven replacement to the Laravel UI package

Home Page: https://github.com/zacksmash/fortify-ui

License: MIT License

PHP 36.65% Blade 63.35%
laravel fortify authentication

fortify-ui's Introduction

Introduction

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

In a nutshell...

FortifyUI automates the base installation and configuration of Laravel Fortify, it includes the features that Laravel Fortify recommends implementing yourself and it provides the scaffolding for you to build your own UI around it. Hence, Fortify + UI.


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

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. This will also publish the service provider and config file for Laravel Fortify. Lastly, it will register both service providers in the app.php config file, under the providers array.

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

Configuration

The FortifyUI service provider registers the views for all of the authentication features. If you'd rather not include the FortifyUI service provider, you can skip generating it by using the --skip-provider flag.

php artisan fortify:ui --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 views required by Laravel Fortify, including basic layout and home views, as well as optional password confirmation, email verification and two-factor authentication 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. Then, go to the fortify.php config file and make sure Features::emailVerification() is uncommented. Next, you'll want to update your User model to include the following:

use Illuminate\Contracts\Auth\MustVerifyEmail;

class User extends Authenticatable implements MustVerifyEmail
{
    ...

This allows you to attach the verified middleware to any of your routes, which is handled by the verify.blade.php file.

More info about this can be found here.

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 get started, visit the FortifyUI Preset Template repository, and click the "Use Template" button.

Community Presets

Here's a list of presets created by the community:

If you've created a preset, please open an issue or PR to add it to the list!

License

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

fortify-ui's People

Contributors

bistory avatar joearcher avatar roelreijneveld avatar steks89 avatar syahzul avatar zacksmash avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fortify-ui's Issues

Can you help me to find out whats going on please?

Hi,
before anything, sorry for my bad English.

First, thank you for what you created for us, then, I really would be thankful if you explain me whole story about these 3 packages you made.

I'm new at Laravel, I started learning last month and at the first of my work, Laravel 8 came and change everything by jetstream and I'm really so confused about it, so I decide use fortify directly without Jetstream for start digging in and made a test project for learning purpose.
And after some search I guessed fortify-ui maybe is best choice for me, but, honestly I don't get what are differences between fortify-uikit & fortify-ui-preset. I'm bad in back-end and I'm worse in front-end! (but I don't give up for learning them better.)

Can you explain the relationships between fortify-ui, fortify-uikit & fortify-ui-preset and help understand whole story from above please?

I need made a simple ui for fortify with Tailwind and without any js.
I read the docs, i understood the fortify-ui is the base and we use other two packages for building front-end, but I need some guide and a road map to understand to from where I should begin for make a ui for it.

I know, this is a weird issue that I made :) but I'm kind of amateur in these stuff and I really would be happy if you tell me whole story and help me figure out where I should start for a make a simple ui for fortify with Tailwind and NO js.

And please consider me as a so new Laravel guy and explain me this in a simple word.

Thank you a lot.

validateWithBag not found in Fortify Actions

Hi, unfortunately Fortify UI is giving me some issues. app/Actions/Fortify/UpdateUserPassword and UpdateUserProfileInformation files call validateWithBag, but for some reason intelephense (VS Code) is marking it as undefined. (see screenshot).

Not really sure why this is happening, as it doesn't seem like this is a common issue. It definitely isn't due to my other code in the project, because even when I created a fresh new Laravel project and installed Fortify UI, it was still giving me the error.

Maybe it's an issue with VS Code? On a related note, in my view files for updating user passwords, error messages {{ $errors }} aren't returned even with invalid inputs. Am I retrieving the errors correctly?

Any help appreciated!
Thanks!
image

PHP 7.3

Hi.
Why is 7.4 written in the dependencies, although it requires 7.3 in Fortify?

Browser Sessions

Could you Add a browser sessions feature, like the one in jetstream?

Created a preset

Hi @zacksmash

I don't know if you're planning on maintaining a list of presets created by the community but I've created a preset based on the Tabler framework. It would be really nice if you could include a link to my work.

The preset is can be found here.

By the way, thanks for your work! It really makes starting Laravel Fortify applications way quicker and easier.

Safe to remove package ofter installing?

Is it true that after running php artisan fortify:ui the package can be safely removed again?
Wouldn't it be better/safer to run composer require --dev zacksmash/fortify-ui instead?

File does not exist at path /***/app/providers/RouteServiceProvider.php.

Hi there,
First of all massive thanks for the module. It has helped me a lot.
But after I tried to install it again in a (fresh) Laravel installation I got the following error message in my console:

 File does not exist at path /***/app/providers/RouteServiceProvider.php.

I installed a fresh Laravel application by running composer create-project laravel/laravel example-app, then running composer require zacksmash/fortify-ui and php artisan fortify-ui:install.

This is the complete error:

***@***:~/***$ php artisan fortify-ui:install --verbose

   Illuminate\Contracts\Filesystem\FileNotFoundException

  File does not exist at path /***/app/providers/RouteServiceProvider.php.

  at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:57
     53▕         if ($this->isFile($path)) {
     54▕             return $lock ? $this->sharedGet($path) : file_get_contents($path);
     55▕         }
     56▕
  ➜  57▕         throw new FileNotFoundException("File does not exist at path {$path}.");
     58▕     }
     59▕
     60▕     /**
     61▕      * Get contents of a file with shared access.

  1   vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
      Illuminate\Filesystem\Filesystem::get()

  2   vendor/zacksmash/fortify-ui/src/Commands/FortifyUICommand.php:92
      Illuminate\Support\Facades\Facade::__callStatic()

  3   vendor/zacksmash/fortify-ui/src/Commands/FortifyUICommand.php:19
      Zacksmash\FortifyUI\Commands\FortifyUICommand::updateRoutes()

  4   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
      Zacksmash\FortifyUI\Commands\FortifyUICommand::handle()

  5   vendor/laravel/framework/src/Illuminate/Container/Util.php:40
      Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

  6   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
      Illuminate\Container\Util::unwrapIfClosure()

  7   vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
      Illuminate\Container\BoundMethod::callBoundMethod()

  8   vendor/laravel/framework/src/Illuminate/Container/Container.php:610
      Illuminate\Container\BoundMethod::call()

  9   vendor/laravel/framework/src/Illuminate/Console/Command.php:136
      Illuminate\Container\Container::call()

  10  vendor/symfony/console/Command/Command.php:255
      Illuminate\Console\Command::execute()

  11  vendor/laravel/framework/src/Illuminate/Console/Command.php:121
      Symfony\Component\Console\Command\Command::run()

  12  vendor/symfony/console/Application.php:971
      Illuminate\Console\Command::run()

  13  vendor/symfony/console/Application.php:290
      Symfony\Component\Console\Application::doRunCommand()

  14  vendor/symfony/console/Application.php:166
      Symfony\Component\Console\Application::doRun()

  15  vendor/laravel/framework/src/Illuminate/Console/Application.php:93
      Symfony\Component\Console\Application::run()

  16  vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:129
      Illuminate\Console\Application::run()

  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Do you have any idea of what I might be doing wrong? Would love to hear from you!

Difference to Fortify?

Don't get me wrong, I appreciate any effort to give alternatives to jetstream - but what is exactly the difference that this package offers over just doing what the fortify readme tells you to? (besides basic blade views?) - creating some views, registering them via Fortify:: facades, ..?

Is this basically just to automate said process and if you do go through the fortify steps yourself, you get the same exact outcome? I feel many have this question trying to migrate over, so please don't see this as an attack on your efforts and work to offer alternatives, just trying to understand if one needs this if they can just do the same as the fortify readme tells.

Of course automation and even creating your own bundle via https://github.com/zacksmash/fortify-ui-preset is extremely neat to have, just trying to distinguish what exactly this does or offers over just doing it "manually", e.g. having to add 2auth functions yourself or alikes? does this implement the things (2fa, ..) that fortify mentions you'll have to do "yourself"?

Again, thanks! 🎉

When I click the "Enable Two-Factor" button I get an error

When I click the "Enable Two-Factor" button I get the following error:

Target [Laravel\Fortify\Contracts\ConfirmPasswordViewResponse] is not instantiable.

The url it takes me to is:

/user/confirm-password

but I don't a user folder with a confirm-password blade. There is a confirm-password blade file in the auth folder. Is it supposed to route to that one?

--

EDIT: I realized uncommenting the following lines in the FortifyUIServiceProvider fixes the error:

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

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

However I get the following error:

Call to undefined method App\Models\User::twoFactorQrCodeSvg()

Looks like it's the part that would display an image for Google Authenticator but it seems this class doesn't exist. Could use a little help.

2FA & E-mail verification

Hi there.

Just trying fortify-ui on a clean Laravel installation. Got the following message when to enable 2FA:

BadMethodCallException
Call to undefined method App\Models\User::twoFactorQrCodeSvg() (View: D:\laragon\www\saas\resources\views\profile\two-factor-authentication-form.blade.php)
http://saas.test/dashboard

Edit 2: For the 2FA i had to set "use HasFactory, Notifiable, TwoFactorAuthenticatable;" in my user modal.

Edit: To enable the verifyemail I also had to "class User extends Authenticatable implements MustVerifyEmail" <<

Can be closed.

HRR

Thank you!

This was exactly what I was looking for and I just want to say thank you for making this available for everyone.

I do have one question though. Does this work with Laravel 9?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.