filament icon indicating copy to clipboard operation
filament copied to clipboard

Add panel option to customize auth routes

Open juliangums opened this issue 1 year ago • 5 comments

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 [email protected] 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

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar

juliangums avatar Jul 02 '24 13:07 juliangums

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.

github-actions[bot] avatar Jul 02 '24 13:07 github-actions[bot]

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

danharrin avatar Jul 03 '24 16:07 danharrin

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

github-actions[bot] avatar Jul 05 '24 13:07 github-actions[bot]

@danharrin updated this with a repo and instructions.

juliangums avatar Jul 05 '24 13:07 juliangums

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.

juliangums avatar Jul 06 '24 12:07 juliangums

You may do this in v3 onwards

->login(fn () => redirect('url here'))

danharrin avatar Dec 18 '24 12:12 danharrin

This applies to all auth routes, where you can pass in a "route action"

danharrin avatar Dec 18 '24 12:12 danharrin