You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 19, 2025. It is now read-only.
A two-factor authentication package for Laravel >= 5.5
7
+
A two-factor authentication package for _Laravel_ >= 5.5
8
8
9
9
## Description
10
-
This is a two-factor authentication package for *Laravel*. It is heavily inspired by the [Laravel Two-Factor Authentication](https://github.com/srmklive/laravel-twofactor-authentication) package. The main differences between this package and the aforementioned package are:
10
+
This is a two-factor authentication package for _Laravel_. It is heavily inspired by the [Laravel Two-Factor Authentication](https://github.com/srmklive/laravel-twofactor-authentication) package. The main differences between this package and the aforementioned package are:
11
11
12
12
- This package currently only works with the *MessageBird Verify* api or the `'null'` driver that goes through all the steps of the two-factor authentication process without actually doing any real verification. This could be useful for testing purposes.
13
13
- This package uses throttling to limit the number of unsuccessful authentication attempts in a certain amount of time.
14
-
- The current version of this package is only guaranteed to work with Laravel >= 5.5. Version 1.* of this package works with Laravel 5.4. Versions of Laravel prior to 5.4 have not been tested.
14
+
- The current version of this package is only guaranteed to work with _Laravel_ >= 5.5. Version 1.* of this package works with _Laravel_ 5.4. Versions of _Laravel_ prior to 5.4 have not been tested.
15
+
16
+
## Important
17
+
From _Laravel_ 5.8 and onwards, the default is to use `bigIncrements` instead of `increments` for the `id` column on the `users` table. As such, the default for this package is to use the same convention for the `user_id` column on the `two_factor_auths` table. If this is not what you want, you can change this in the published config file by setting the "big_int" option to `false`.
18
+
19
+
For users who have already installed this package and hence, already have ran the migrations for this package there are essentially two different scenarios:
20
+
21
+
1. You upgrade from _Laravel_ < 5.8 to 5.8 or later and have decided to keep using `increments` for the `id` column on the `users` table: You don't have to do anything. You might want to [change](#optional-correction) the signature of the `user_id` column on the `two_factor_auths` table from `increments` to `unsignedInteger` though.
22
+
23
+
2. You upgrade from _Laravel_ < 5.8 to 5.8 or later and have decided to make the switch to `bigIncrements` for the `id` column on the `users` table: You will have to make and run your own migration in order to update the `user_id` column on the `two_factor_auths` table appropriately.
24
+
25
+
### Optional correction
26
+
Versions of this package prior to v2.3.0 incorrectly created the `user_id` column on the `two_factor_auths` table using `increments` instead of `unsignedInteger`. Practically speaking, this error is of no concern. Although there is no need to have a _primary_ key for the `user_id` column, it doesn't cause any problems either. However, if for some reason you don't like this idea, it is safe to remove the _primary_ key using a migration of the form
27
+
28
+
```php
29
+
<?php
30
+
31
+
use Illuminate\Support\Facades\Schema;
32
+
use Illuminate\Database\Schema\Blueprint;
33
+
use Illuminate\Database\Migrations\Migration;
34
+
35
+
class RemovePrimaryFromTwoFactorAuthsTable extends Migration
36
+
{
37
+
/**
38
+
* Run the migrations.
39
+
*
40
+
* @return void
41
+
*/
42
+
public function up()
43
+
{
44
+
Schema::table('two_factor_auths', function (Blueprint $table) {
45
+
$table->dropForeign(['user_id']);
46
+
});
47
+
48
+
Schema::table('two_factor_auths', function (Blueprint $table) {
Note that you will need the [doctrine/dbal](https://packagist.org/packages/doctrine/dbal) package for this migration to work. Furthermore, if the `id` column on your `users` table is of type `bigIncrements` you will have to change the lines `$table->unsignedInteger('user_id')->change();` to `$table->unsignedBigInteger('user_id')->change();` and `$table->increments('user_id')->change();` to `$table->bigIncrements('user_id')->change();` respectively.
15
74
16
75
## Installation
17
76
1. To install using *Composer* run:
@@ -34,13 +93,17 @@ php artisan vendor:publish
34
93
```
35
94
If you want to publish only one of these file groups, for instance if you don't need the views or language files, you can append one of the following commands to the *artisan* command: `--tag=config`, `--tag=lang` or `--tag-views`.
36
95
37
-
4. Run the following *artisan* command to run the database migrations
96
+
4.**Important**: Make sure you do this step _before_ you run any migrations for this package, as otherwise it might give you unexpected results.
97
+
98
+
From _Laravel_ 5.8 and on, the default is to use `bigIncrements` instead of `increments` for the `id` column on the `users` table. As such, the default for this package is to use the same convention for the `user_id` column on the `two_factor_auths` table. If this is not what you want, you can change this in the published config file by setting the "big_int" option to `false`.
99
+
100
+
5. Run the following *artisan* command to run the database migrations
38
101
```
39
102
php artisan migrate
40
103
```
41
104
This will add a `mobile` column to the `users` table and create a `two_factor_auths` table.
42
105
43
-
5. Add the following trait to your `User` model:
106
+
6. Add the following trait to your `User` model:
44
107
```php
45
108
...
46
109
use MichaelDzjap\TwoFactorAuth\TwoFactorAuthenticable;
0 commit comments