F
Filamentβ€’2y ago
Prodex

Laravel Socialite without extra packages

Hi, for my application, I just need to let users login with GitLab oauth2 only. I've already a very simple login page with just one button. So it's unnecessary for me to use another filament package that provides multiple ways, and Laravel Socialite works fine for me already. My question: What would be the best approach to make this work with the filament admin panel? Can I disable or override the login page with my own auth view? And is there anything to consider when using a "custom" auth approach? Thank you!
10 Replies
RickDB
RickDBβ€’2y ago
In the config file you can override the Login class, that should work for you πŸ™‚ Look for this:
'auth' => [
'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
'pages' => [
'login' => \Filament\Http\Livewire\Auth\Login::class,
],
],
'auth' => [
'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
'pages' => [
'login' => \Filament\Http\Livewire\Auth\Login::class,
],
],
Prodex
ProdexOPβ€’2y ago
Thank you! Is there anything else to consider? Except implementing the FilamentUser class (like the docs say).
RickDB
RickDBβ€’2y ago
Not really. Take a look at the existing Login class to see what you need πŸ™‚
Prodex
ProdexOPβ€’2y ago
I need to open this again: If I overwrite the login class I get "Invalid route action" and if I return a route like route('login'), the route cannot be found (although it's configured). What am I missing here? and: I don't understand what method filament calls in the default class, because you configure the whole class instead of calling a specific method. I guess authenticate() will be called, but that's not working in my class either (same route exception). πŸ€”
RickDB
RickDBβ€’2y ago
You don't have to define the route tho just specify the class in the config
Prodex
ProdexOPβ€’2y ago
If I just pass the class then I get Invalid route action: [App\Http\Controllers\Auth\GitLabOAuth2Controller]
RickDB
RickDBβ€’2y ago
hmm
Prodex
ProdexOPβ€’2y ago
Does the controller need something special? If I dd it doesn't even reach the constructor.
RickDB
RickDBβ€’2y ago
i can't debug right now but dont think so
Prodex
ProdexOPβ€’2y ago
after some testing: It needs to be a livewire component and I copied the original class. It works now, but I didn't fully understand it though πŸ˜…
Want results from more Discord servers?
Add your server