lcloss / simple-auth
Auth screens for new Laravel project
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:CSS
Type:package
Requires
- laravel/fortify: ^1.18
README
SimpleAuth is a package to have a quick authorizations screen in conjunction with Laravel Fortify. It is designed with Laravel 10, but may work with other versions. With this package, you can Login, Register, Recover password and handle Email verification.
Installation
-
Install the package via composer:
composer require lcloss/simple-auth
-
Publish the config file:
php artisan vendor:publish --provider="Lcloss\SimpleAuth\SimpleAuthServiceProvider"
-
Publish the Fortify file:
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
-
Regiter
login
andregister
views in the Fortify config file:// app\Providers\FortifyServiceProvider.php public function boot(): void { /* Login */ Fortify::loginView(function () { return view( config('simple-auth.views.login') ); }); /* Register */ Fortify::registerView(function () { return view(config('simple-auth.views.register')); }); // Forgot Password view Fortify::requestPasswordResetLinkView(function () { return view(config('simple-auth.views.forgot-password')); }); // Reset password view Fortify::resetPasswordView(function ($request) { return view(config('simple-auth.views.reset-password'), ['request' => $request]); }); // Verify email view Fortify::verifyEmailView(function () { return view(config('simple-auth.views.verify-email')); }); // Confirm password view Fortify::confirmPasswordView(function () { return view(config('simple-auth.views.confirm-password')); });
-
Create a user name from first and last names:
Note that this version of registration screen came with First name and Last name.
User's table has a name
field, so you can use it to store the full name.
Change the CreateNewUser action to create the name from first and last names:
// app/Actions/Fortify/CreateNewUser.php Validator::make($input, [ 'first_name' => ['required', 'string', 'max:255'], 'last_name' => ['nullable', 'string', 'max:255'], 'email' => [ 'required', 'string', 'email', 'max:255', Rule::unique(User::class), ], 'password' => $this->passwordRules(), 'password_confirmation' => ['required', 'same:password'], ])->validate(); $name = trim($input['first_name'] . ' ' . $input['last_name']);
-
Check the FortifyServiceProvider at
config/app.php
:// config/app.php 'providers' => [ // ... App\Providers\FortifyServiceProvider::class, ],
-
Do the migrations with seed:
php artisan migrate --seed
-
Do the
npm install
andnpm run dev
commands. -
Open your project in the browser and go to
/login
or/register
to see the new views.
Tip: First registration will be the super user.
Configuration
You can change this package's configuration by editing the config/simple-auth.php
file.
TODOs
- Add tests
- Add translations