Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mimachh/mimachh-2fa
2FA for Laravel + Inertia + Breeze
https://github.com/mimachh/mimachh-2fa
composer laravel package
Last synced: 19 days ago
JSON representation
2FA for Laravel + Inertia + Breeze
- Host: GitHub
- URL: https://github.com/mimachh/mimachh-2fa
- Owner: Mimachh
- Created: 2024-11-03T16:41:51.000Z (2 months ago)
- Default Branch: develop
- Last Pushed: 2024-11-23T21:09:08.000Z (about 2 months ago)
- Last Synced: 2024-12-21T09:35:26.146Z (20 days ago)
- Topics: composer, laravel, package
- Language: TypeScript
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Installation
```php
composer require mimachh/2fa
```Add the trait to the user model
```php
use Mimachh\TwoFactor\HasTwoFactor;use HasTwoFactor;
```Publish the migrations and migrate.
```php
php artisan vendor:publish --tag=2fa-migrationsphp artisan migrate
```### Validation
To validate the code you need to add in the LoginRequest of Breeze (if you use Breeze) :
```php
'code_2fa' => ['nullable', 'string', 'size:6'],
```### Routing
Replace your breeze (in auth.php) or custom route login by
```php
Route::post('/login', [TwoFactorController::class, 'store'])->name('login.2fa');
```### UI
You can use the inertia/react login (and register, confirmation mail etc) from the package, publishing them.
You need : ShadcnUI + Inertia + React + Zustand```php
php artisan vendor:publish --tag=2fa-assets
```Then install shadcn component + zustand library and use it in your own page and component.
```sh
npx shadcn@latest add button input label input-otp
npm i zustand
``````tsx
import LoginForm from '@/Components/mimachh/2fa/login/LoginForm';
```
You need to send email with the 2fa code.First publish the mail view :
```sh
php artisan vendor:publish --tag=2fa-mail
```Now email will work.