Custom Login

Yo, So I am now trying to implement my custom packages from work, and the first being making use of our User Package which has it's own authentication. How do I update the login process functionality to point to my existing route. Assuming it's apart of this panel?
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => Color::hex('#b41be3'),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
// ->databaseNotifications()
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
])
->sidebarCollapsibleOnDesktop();
return $panel
->default()
->id('admin')
->path('admin')
->login()
->colors([
'primary' => Color::hex('#b41be3'),
])
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
// Widgets\FilamentInfoWidget::class,
])
// ->databaseNotifications()
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
])
->authMiddleware([
Authenticate::class,
])
->sidebarCollapsibleOnDesktop();
I have tried pasting the route inside login() but says it's not defined.
Solution:
->login([Controller::class, 'login'])
->login([Controller::class, 'login'])
This does seem to point to the controller function, so this may actually also cover what I need, until further testing...
Jump to solution
9 Replies
Jamie Cee
Jamie Cee12mo ago
And another issue, I have my local User model extending my in house package User Model, and in my local model, I am trying to implement the HasName interface but it's not detecting.
Class PackageUser{}

Class User extends PackageUser implements HasName {}
Class PackageUser{}

Class User extends PackageUser implements HasName {}
I have included the imports, just no luck. If I manually add HasName in the PackageUser, it detects it as an instanceof HasName, but I dont want to be writing into a vendor package For context to the message above ^. The PackageUser extends Authenticatable, but since the function below, also looks for Model. It should work fine?
public function getUserName(Model | Authenticatable $user): string
{
if ($user instanceof HasName) {
return $user->getFilamentName();
}

return $user->getAttributeValue('name');
}
public function getUserName(Model | Authenticatable $user): string
{
if ($user instanceof HasName) {
return $user->getFilamentName();
}

return $user->getAttributeValue('name');
}
And I have bound my package model to my project model in my AppServiceProvider.
developer
developer12mo ago
hey did you find a solution?
awcodes
awcodes12mo ago
You didn’t pass your custom login class to the ->login() method on your panel. I’d start there.
Jamie Cee
Jamie Cee12mo ago
So is that the controller? I did try the model but that didn't work I did also try calling the route() but it complained that route didn't exist, but it did
Dennis Koch
Dennis Koch12mo ago
I think it needs to be a Livewire component 🤔
Jamie Cee
Jamie Cee12mo ago
Don't suppose you could draft a quick example, (im a visual learner 🤣 )
Dennis Koch
Dennis Koch12mo ago
Of a Livewire component? Default config is $panel->login(Login::class). You can check out that login class for an example
Solution
Jamie Cee
Jamie Cee12mo ago
->login([Controller::class, 'login'])
->login([Controller::class, 'login'])
This does seem to point to the controller function, so this may actually also cover what I need, until further testing
Jamie Cee
Jamie Cee12mo ago
THis should cover the earlier issue I had of it not detecting the local User thing https://discord.com/channels/883083792112300104/1136587839874814033/1136593537278947329 As if we end up implementing to the user package instead of local project, it shouldn't complain. This was a strange one though