filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
16.1k stars 2.57k forks source link

Add panel option to customize auth routes #13454

Open juliangums opened 1 week ago

juliangums commented 1 week ago

Package

filament/filament

Package Version

latest

Laravel Version

latest

Livewire Version

latest

PHP Version

latest

Problem description

The issue is outlined in these two discussions: https://github.com/filamentphp/filament/discussions/11705 https://github.com/filamentphp/filament/discussions/13431

If I have multiple panels sharing the same login, I need to be able to set a login redirect URL on the panels that don't have their own login.

Expected behavior

We need to have an option to specify the login redirect route of another panel.

Steps to reproduce

  1. Clone the repos
  2. Migrate and seed the database
  3. Open the app and log in with admin@admin.com and admin.
  4. You are in the noteam panel. Logging out from here will work. But if you navigate to the team panel by replacing noteam with team in the URL, and you try to log out, you will be redirected to the generic login route which does not exist.

Reproduction repository (issue will be closed if this is not valid)

https://github.com/juliangums/filament-multi-panel-auth-test

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

github-actions[bot] commented 1 week ago

Hey @juliangums! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.

Also, it doesn't look like you've provided much information on how to replicate the issue. Please edit your original post with clear steps we need to take.

danharrin commented 1 week ago

Can you please reproduce the redirect issue and write a few steps as to how to get there

github-actions[bot] commented 1 week ago

Thank you for providing reproduction steps! Reopening the issue now.

juliangums commented 1 week ago

@danharrin updated this with a repo and instructions.

juliangums commented 1 week ago

Basically if I extend the Panel and override this method from HasAuth

    public function getLoginUrl(array $parameters = []): ?string
    {
        if (! $this->hasLogin()) {
            return null;
        }

        return $this->route('auth.login', $parameters);
    }

I can get the desired outcome. I will do that for now, but it might be an option to create a setter, so people can override it without extending Panel.