Skip to content

Commit d769ba0

Browse files
committed
Routes can now be explicitly defined using config file. More flexibility.
1 parent fd7ee60 commit d769ba0

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

config/2fa-config.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
*/
99
'redirect_to' => '/home',
1010

11+
/*
12+
* Routes
13+
* Change the routes if your existing routes
14+
* conflicts with existing routes.
15+
*/
16+
'setup_2fa' => 'setup-2fa',
17+
'enable_2fa' => 'enable-2fa',
18+
'disable_2fa' => 'disable-2fa',
19+
1120
/*
1221
* Account name which will be used as label to show on
1322
* authenticator mobile application.
@@ -25,12 +34,15 @@
2534

2635
/*
2736
* Size of Base32 encoded secret key.
28-
* Default 10.
29-
* Note. Keeping Secret key in multiple of
30-
* 5 would result secret key not padded
31-
* with equal to symbols.
37+
* Default 6 Works with GA and Authy.
38+
*/
39+
'number_of_digits' => 6,
40+
41+
/*
42+
* The Number of Seconds the code will be valid.
43+
* Default 30.
3244
*/
33-
'number_of_digits' => 10,
45+
'period' => 30,
3446

3547
/*
3648
* Explitcitly Define Table name for the model.

src/Http/Controllers/TwoFactorAuthenticationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function setupTwoFactorAuthentication(Request $request)
5050
$totp = new TOTP(
5151
config('2fa-config.account_name'),
5252
$user->two_factor_secret_key,
53-
10,
53+
config('2fa-config.period'),
5454
config('2fa-config.digest_algorithm'),
5555
config('2fa-config.number_of_digits')
5656
);

src/routes/routes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Route::group(['middleware' => ['web'], 'namespace' => '\Thecodework\TwoFactorAuthentication\Http\Controllers'], function () {
44
Route::get('verify-2fa', 'TwoFactorAuthenticationController@verifyTwoFactorAuthentication');
55
Route::post('verify-2fa', 'TwoFactorAuthenticationController@verifyToken');
6-
Route::get('setup-2fa', 'TwoFactorAuthenticationController@setupTwoFactorAuthentication');
7-
Route::post('enable-2fa', 'TwoFactorAuthenticationController@enableTwoFactorAuthentication');
8-
Route::post('disable-2fa', 'TwoFactorAuthenticationController@disableTwoFactorAuthentication');
6+
Route::get(config('2fa-config.setup_2fa'), 'TwoFactorAuthenticationController@setupTwoFactorAuthentication');
7+
Route::post(config('2fa-config.enable_2fa'), 'TwoFactorAuthenticationController@enableTwoFactorAuthentication');
8+
Route::post(config('2fa-config.disable_2fa'), 'TwoFactorAuthenticationController@disableTwoFactorAuthentication');
99
});

0 commit comments

Comments
 (0)