vormkracht10 / filament-2fa

Integrate Laravel Fortify easily in your Filament apps.
MIT License
32 stars 2 forks source link

[Bug]: Attempt to read property "value" on null error #47

Open enessvg opened 2 hours ago

enessvg commented 2 hours ago

What happened?

hello, I installed the plugin and opened 2fa, then when I tried to log in, I got an error like this: Attempt to read property “value” on null

In order to resolve this error vendor\vormkracht10\filament-2fa\src\Http\Livewire\Auth\LoginTwoFactor.php In line 44 $this->twoFactorType = $this->challengedUser->two_factor_type->value; It worked when I removed the value from the code, what is this caused by? can you check?

Translated with DeepL.com (free version)

How to reproduce the bug

Bu hatayı çözmek içinde vendor\vormkracht10\filament-2fa\src\Http\Livewire\Auth\LoginTwoFactor.php

  1. satırdaki $this->twoFactorType = $this->challengedUser->two_factor_type->value; kodundan valueyi kaldırınca çalıştı bu neyden kaynaklanıyor? kontrol edermisiniz?

Package Version

1.6^

PHP Version

8.2.4

Laravel Version

11.0.0

Which operating systems does with happen with?

Windows

Notes

No response

Baspa commented 2 hours ago

Did you follow all the installation steps from the readme? @enessvg

enessvg commented 2 hours ago

@Baspa Yes

Baspa commented 2 hours ago

Can you provide me a reproduction repository? Then I'll be happy to help @enessvg

enessvg commented 2 hours ago

I can't provide it right now, but I can leave photos like this: image

Deleted value code: $this->twoFactorType = $this->challengedUser->two_factor_type;

image

@Baspa Maybe it's my fault, I'll install it in another project and try again. But as I said, I did the installation completely by following https://filamentphp.com/plugins/vormkracht10-2fa

Baspa commented 2 hours ago

Did you run migrations? Can you show me your user model and did you setup 2FA for the user? @enessvg

enessvg commented 2 hours ago

Did you run migrations? Can you show me your user model and did you setup 2FA for the user? @enessvg

Yes, I've run migrations. @Baspa

User.php: use Laravel\Fortify\TwoFactorAuthenticatable; use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType;

use HasFactory, Notifiable, HasRoles, HasPanelShield, TwoFactorAuthenticatable;

protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'two_factor_type' => TwoFactorType::class, ]; }