Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package not using the authentication guard setup in filament config #61

Open
neamtua opened this issue May 29, 2023 · 7 comments
Open

Comments

@neamtua
Copy link

neamtua commented May 29, 2023

I have two authentication guards. The filament package is using a special admin one that uses a different table and model than the default users configured in laravel.
First thing i've noticed is that when i view an event in filament the user field is empty.

Second issue is after logging in with the regular auth guard. This package throws an error because it's trying to call some filament username function that obviously isn't defined on the regular Users model.

Here's a screenshot of the error.

CleanShot 2023-05-29 at 10 31 46@2x

For now, the quickest solution was to disable the access logger from the package config.
I can probably override the Logger and try and make it use only the admin guard but that would mean i'd have to override all the guards to properly get the username in all the other logs.

Bottom line, I think the package needs an update to read filament.auth.guard config value and apply that to all the logging.

@Z3d0X
Copy link
Owner

Z3d0X commented Jun 10, 2023

Please make sure your model is configured for filament,

https://filamentphp.com/docs/2.x/admin/users#configuring-the-name-attribute

@faizananwerali
Copy link

I can confirm different guards are not working.

I use the admin_users table and AdminUser Model for filament.

This package is not compatible with multi-guard yet.

Screenshot 2023-07-10 at 12 24 46 AM

@Z3d0X
Copy link
Owner

Z3d0X commented Jul 10, 2023

I use the admin_users table and AdminUser Model for filament.

This package is not compatible with multi-guard yet.
Screenshot 2023-07-10 at 12 24 46 AM

Could you check activity_log table on the database and confirm the whether the following columns are empty for the log shown in the screenshot: causer_type, causer_id

@faizananwerali
Copy link

faizananwerali commented Jul 10, 2023 via email

@mrozek90
Copy link

I have a similar issue, but in my DB causer_type and causer_id are exists.

for example:
causer_type => App\Models\User
causer_id => 1

'Description' and 'Properties' shown in right way with 'First name Last name'

example desc:
resourceName Updated by firstName lastName

But User Reference doesn't appear anywhere.

Suggest?

@riodwanto
Copy link

I have a similar issue, but in my DB causer_type and causer_id are exists.

for example: causer_type => App\Models\User causer_id => 1

'Description' and 'Properties' shown in right way with 'First name Last name'

example desc: resourceName Updated by firstName lastName

But User Reference doesn't appear anywhere.

Suggest?

Default attribute is causer.name. So, i assumed your User Table doesn't have name field. in that case, u should add:

// Define an accessor for the 'name' attribute
public function getNameAttribute()
{
    return "{$this->firstName} {$this->lastName}";
}

in your User Model.

@mrozek90
Copy link

getNameAttribute()
It work only in description field but nowhere else.

filament-logger/src/Resources

/ActivityResource.php

//...//
 TextInput::make('causer_id')
                            ->afterStateHydrated(function ($component, ?Model $record) {
                                /** @phpstan-ignore-next-line */
                                **return $component->state($record->causer?->name);**
                            })
                            //...//

If fix it in my way.
If someone had like I: username and/or first_name, last_name but not have a 'name' column in database:
(User not showing in Log Preview)

return $component->state($record->causer?->username); //or last_name etc.

Hardcoded quick-fix :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants