diogogpinto / filament-auth-ui-enhancer

This Filament plugin empowers you to transform your auth pages with ease, allowing you to make them truly stand out. It offers a flexible alternative to the default auth pages in the Filament Panels package.
MIT License
47 stars 2 forks source link

[Bug]: Does not work when panel path/id is not 'admin' #8

Closed diegobas closed 3 days ago

diegobas commented 4 days ago

What happened?

When you define your panel id to something different from 'admin' the login action gives this error:

Unable to find component: [diogo-g-pinto.auth-u-i-enhancer.pages.auth.auth-ui-enhancer-login]

How to reproduce the bug

public function panel(Panel $panel): Panel
{
    return $panel
        ...
        ->id('manage')
        ->path('manage')
        ->login()
       ...
}

It works when panel ID is 'admin'

Package Version

1.0.1

PHP Version

8.3

Laravel Version

11.29.0

Which operating systems does with happen with?

Linux

Notes

No response

diogogpinto commented 3 days ago

Hey @diegobas

I just tried out with a panel much like yours and it worked fine:

ManagePanelProvider.php:

        return $panel
            ->default()
            ->id('manage')
            ->path('manage')
            ->login(Login::class)
            ->passwordReset()
            ->registration()
            ->viteTheme('resources/css/filament/manage/theme.css')

vite.config.js:

    plugins: [
        laravel.default({
            input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/manage/theme.css'],
            refresh: [
                ...refreshPaths,
                'app/Filament/**',
                'app/Forms/Components/**',
                'app/Livewire/**',
                'app/Infolists/Components/**',
                'app/Providers/Filament/**',
                'app/Tables/Columns/**',
            ],
        }),
    ],

resources/css/filament/manage/tailwind.config.js:

import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/Clusters/Products/**/*.php',
        './resources/views/filament/clusters/products/**/*.blade.php',
        './vendor/filament/**/*.blade.php',
        './vendor/diogogpinto/filament-auth-ui-enhancer/resources/**/*.blade.php',
    ],
}
diegobas commented 3 days ago

Maybe a conflict with another plugin?

https://github.com/user-attachments/assets/a7fae65a-dfa6-46f3-a20d-5c13edf52618

PlpadminPanelProvider:

return $panel
            ->default()
            ->id('plpadmin')
            ->path('plpadmin')
            ->login()
            ->databaseNotifications()
            ->colors([
                'primary' => Color::Sky,
                'blue' => Color::Blue,
                'green' => Color::Green,
                'orange' => Color::Orange,
                'red' => Color::Red,
                'yellow' => Color::Yellow,
                'gray' => Color::Gray,
                'indigo' => Color::Indigo,
                'purple' => Color::Purple,
                'pink' => Color::Pink,
                'teal' => Color::Teal,
                'lime' => Color::Lime,
                'emerald' => Color::Emerald,
                'cyan' => Color::Cyan
            ])
            ->viteTheme('resources/css/filament/plpadmin/theme.css')
            ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
            ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
            ->pages([
                \App\Filament\Pages\Dashboard::class,
            ])
            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
            ->widgets([
                Widgets\AccountWidget::class,
                Widgets\FilamentInfoWidget::class,
            ])
            ->plugins([
                \BezhanSalleh\FilamentShield\FilamentShieldPlugin::make(),
                \Jeffgreco13\FilamentBreezy\BreezyCore::make()
                    ->enableSanctumTokens(
                        permissions: ['create','view','update'] // optional, customize the permissions (default = ["create", "view", "update", "delete"])
                    )
                    ->myProfile(
                        shouldRegisterUserMenu: true, // Sets the 'account' link in the panel User Menu (default = true)
                        shouldRegisterNavigation: false, // Adds a main navigation item for the My Profile page (default = false)
                        navigationGroup: 'Settings', // Sets the navigation group for the My Profile page (default = null)
                        hasAvatars: false, // Enables the avatar upload form component (default = false)
                        slug: 'profile' // Sets the slug for the profile page (default = 'my-profile')
                    ),

            ])
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([
                Authenticate::class,
            ]);

vite.config.js

import { defineConfig } from 'vite';
import laravel, { refreshPaths } from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/css/filament/plpadmin/theme.css',
                'resources/js/app.js'
            ],
            refresh: [
                ...refreshPaths,
                'app/Livewire/**'
            ],
        }),
    ],
});

resources/css/filament/plpadmin/tailwind.config.js:

import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/**/*.php',
        './resources/views/filament/**/*.blade.php',
        './resources/views/components/**/*.blade.php',
        './vendor/filament/**/*.blade.php',
        './vendor/awcodes/filament-tiptap-editor/resources/**/*.blade.php',
        './vendor/diogogpinto/filament-auth-ui-enhancer/resources/**/*.blade.php',
    ],
}
diogogpinto commented 3 days ago

I will replicate your workflow and see what’s causing this!

diogogpinto commented 3 days ago

I just replicated all the your code and it's working fine, with no issues. Here's my step by step:

  1. Run composer update
  2. Install plugins (Filament Auth Ui, Filament Shield and Filament Breezy)
  3. Create new panel with php artisan make:filament-panel and name it plpadmin
  4. Create a new theme with php artisan make:filament-theme and select the plpadmin panel
  5. Add the following code to my filament panel (replica of your panel)
<?php

namespace App\Providers\Filament;

use DiogoGPinto\AuthUIEnhancer\AuthUIEnhancerPlugin;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;

class PlpadminPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('plpadmin')
            ->path('plpadmin')
            ->login()
            ->databaseNotifications()
            ->colors([
                'primary' => Color::Sky,
                'blue' => Color::Blue,
                'green' => Color::Green,
                'orange' => Color::Orange,
                'red' => Color::Red,
                'yellow' => Color::Yellow,
                'gray' => Color::Gray,
                'indigo' => Color::Indigo,
                'purple' => Color::Purple,
                'pink' => Color::Pink,
                'teal' => Color::Teal,
                'lime' => Color::Lime,
                'emerald' => Color::Emerald,
                'cyan' => Color::Cyan,
            ])
            ->viteTheme('resources/css/filament/plpadmin/theme.css')
            ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
            ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
            ->pages([
                \App\Filament\Pages\Dashboard::class,
            ])
            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
            ->widgets([
                Widgets\AccountWidget::class,
                Widgets\FilamentInfoWidget::class,
            ])
            ->plugins([
                \BezhanSalleh\FilamentShield\FilamentShieldPlugin::make(),
                \Jeffgreco13\FilamentBreezy\BreezyCore::make()
                    ->enableSanctumTokens(
                        permissions: ['create', 'view', 'update'] // optional, customize the permissions (default = ["create", "view", "update", "delete"])
                    )
                    ->myProfile(
                        shouldRegisterUserMenu: true, // Sets the 'account' link in the panel User Menu (default = true)
                        shouldRegisterNavigation: false, // Adds a main navigation item for the My Profile page (default = false)
                        navigationGroup: 'Settings', // Sets the navigation group for the My Profile page (default = null)
                        hasAvatars: false, // Enables the avatar upload form component (default = false)
                        slug: 'profile' // Sets the slug for the profile page (default = 'my-profile')
                    ),
                AuthUIEnhancerPlugin::make(),
            ])
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                AuthenticateSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ])
            ->authMiddleware([
                Authenticate::class,
            ]);
    }
}
  1. My /vite.config.js file:
import { defineConfig } from 'vite'
import laravel, { refreshPaths } from 'laravel-vite-plugin'

export default defineConfig({
    plugins: [
        laravel.default({
            input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/plpadmin/theme.css'],
            refresh: [
                ...refreshPaths,
                'app/Filament/**',
                'app/Forms/Components/**',
                'app/Livewire/**',
                'app/Infolists/Components/**',
                'app/Providers/Filament/**',
                'app/Tables/Columns/**',
            ],
        }),
    ],
})
  1. My /resources/css/filament/plpadmin/tailwind.config.js
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
    presets: [preset],
    content: [
        './app/Filament/**/*.php',
        './resources/views/filament/**/*.blade.php',
        './vendor/filament/**/*.blade.php',
        './vendor/awcodes/filament-tiptap-editor/resources/**/*.blade.php',
        './vendor/diogogpinto/filament-auth-ui-enhancer/resources/**/*.blade.php',
    ],
}
  1. Go to the root of the project and run npm run build
  2. Here's the result:
Captura de ecrã 2024-10-23, às 18 05 56 Captura de ecrã 2024-10-23, às 18 06 05

I'm closing this for now, because as this is probably a misconfiguration on your end. If you can create a repo that mimics that behaviour and I clone to my machine to test it out, please reopen this issue.

Thank you, let me know if I can help further!

diegobas commented 3 days ago

Problem solved!

I had to remove the file "bootstrap/cache/filament/panels/plpadmin.php" because "php artisan cache:clear" did not.

Thank you for your help and your great work!

diogogpinto commented 3 days ago

Thank you for you feedback @diegobas and kind words!