Skip to content

Commit 73c597b

Browse files
committed
Now not using too generic name for table columns. close #23
1 parent 4904e11 commit 73c597b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

database/migrations/2017_03_18_000012_add_two_factor_authentication_required_fields.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class AddTwoFactorAuthenticationRequiredFields extends Migration
1414
public function up()
1515
{
1616
Schema::table('users', function (Blueprint $table) {
17-
$table->smallInteger('is_2fa_enabled')->default(0)->before('create_at');
18-
$table->string('secret_key')->nullable()->after('is_2fa_enabled');
17+
$table->smallInteger('is_two_factor_enabled')->default(0)->before('create_at');
18+
$table->string('two_factor_secret_key')->nullable()->after('is_2fa_enabled');
1919
});
2020
}
2121

@@ -27,8 +27,8 @@ public function up()
2727
public function down()
2828
{
2929
Schema::table('users', function (Blueprint $table) {
30-
$table->dropColumn('is_2fa_enabled');
31-
$table->dropColumn('secret_key');
30+
$table->dropColumn('is_two_factor_enabled');
31+
$table->dropColumn('two_factor_secret_key');
3232
});
3333
}
3434
}

src/AuthenticatesUsersWith2FA.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait AuthenticatesUsersWith2FA
2727
*/
2828
protected function authenticated(Request $request, $user)
2929
{
30-
if ($user->is_2fa_enabled) {
30+
if ($user->is_two_factor_enabled) {
3131
$request->session()->put('2fa:user:id', encrypt($user->id));
3232
$secret = getenv('HMAC_SECRET');
3333
$signature = hash_hmac('sha256', $user->id, $secret);
@@ -61,7 +61,7 @@ public function verifyToken(Request $request)
6161
Validator::extendImplicit('valid_token', function ($attribute, $value) {
6262
$totp = new TOTP(
6363
config('2fa-config.account_name'),
64-
$this->user->secret_key
64+
$this->user->two_factor_secret_key
6565
);
6666

6767
return $value == $totp->now();

src/Http/Controllers/TwoFactorAuthenticationController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function setupTwoFactorAuthentication(Request $request)
2424
{
2525
$secret_key = $this->base32EncodedString(config('2fa-config.number_of_digits'));
2626
$user = User::find($request->user()->id);
27-
$user->secret_key = $secret_key;
27+
$user->two_factor_secret_key = $secret_key;
2828
$user->update();
2929
$totp = new TOTP(
3030
config('2fa-config.account_name'),
@@ -49,7 +49,7 @@ public function setupTwoFactorAuthentication(Request $request)
4949
public function enableTwoFactorAuthentication(Request $request)
5050
{
5151
$user = User::find($request->user()->id);
52-
$user->is_2fa_enabled = 1;
52+
$user->is_two_factor_enabled = 1;
5353
$user->update();
5454

5555
return redirect('home');

0 commit comments

Comments
 (0)