Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/masoudghadimi/twofactorauth
Laravel Two-Factor Authenticated For Laravel/Ui
https://github.com/masoudghadimi/twofactorauth
laravel-two-factor-auth laravel8 two-factor-authentication twofactorauth
Last synced: about 2 months ago
JSON representation
Laravel Two-Factor Authenticated For Laravel/Ui
- Host: GitHub
- URL: https://github.com/masoudghadimi/twofactorauth
- Owner: masoudghadimi
- License: mit
- Archived: true
- Created: 2021-03-06T10:53:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-05-07T13:54:34.000Z (over 3 years ago)
- Last Synced: 2024-09-30T16:53:42.976Z (about 2 months ago)
- Topics: laravel-two-factor-auth, laravel8, two-factor-authentication, twofactorauth
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
twoFactorAuth
Laravel Two-Factor Authenticated For Laravel/Ui
This package is being developed and debugged
Install
1) Install package - using composer
`composer require masoudghadimi/two-factor-auth`
2) Publish configuration file
`php artisan vendor:publish --tag=twoFactor`
3) Migration
`php artisan migrate`
4) Update User model (app/Models/User)
```php
protected $fillable = [
'name',
'email',
'password',
'phone_number',
'two_factor_type'
];```
5) Add this codes to the User model (app/Models/User)
```php
public function verifyCodes()
{
return $this->hasMany(VerifyCode::class);
}```
6) Add this codes to the LoginController (app/Http/Auth/LoginController)
```php
use TwoFactorAuthenticate;protected function authenticated(Request $request, $user)
{
return $this->loggedIn($request , $user);
}```
Configuration
Open configuration file - config/twoFactor.php
- Detect the channel
- change the route prefix
- Change the expiration time
- Change the number of digits in the codeNext step
Create channel file and then put it in the config file (notificationsChannels)
For example :
create SmsVerifyCodeChannel.php in app/channels then enter your desired code as below
```php
class SmsVerifyCodeChannel
{
public function send($notifiable, Notification $notification)
{
if (! method_exists($notification , 'toSendVerifyCode')) {
throw new \Exception('toSendVerifyCode not found');
}$data = $notification->toSendVerifyCode($notifiable);
$message = $data['message'];
$phone = $data['number'];try{
$lineNumber = 1111111;
$api = new \Ghasedak\GhasedakApi('token');
$api->SendSimple($phone, $message, $lineNumber);
}
catch(ApiException $e){
echo $e->errorMessage();
}
catch(HttpException $e){
echo $e->errorMessage();
}
}
}```
Next, enter the config/twofactor.php file and in the notificationsChannels section, enter the created channel as follows:
```php
'notificationsChannels' => \App\channels\SmsVerifyCodeChannel::class,
```
Last step
Go to the link below :
`
localhost:8000/home/security
`Good luck