Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Passwordless Login Laravel Package

spykapps/filament-passwordless-login

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Install the package:

    composer require spykapps/filament-passwordless-login
    

    This auto-installs spykapps/passwordless-login as a dependency.

  2. Publish migrations and config:

    php artisan vendor:publish --tag=passwordless-login-config
    php artisan vendor:publish --tag=passwordless-login-migrations
    php artisan migrate
    
  3. Add the trait to your User model:

    use SpykApp\PasswordlessLogin\Traits\HasMagicLogin;
    
    class User extends Authenticatable
    {
        use HasMagicLogin;
    }
    
  4. Register the plugin in your panel provider:

    use SpykApp\FilamentPasswordlessLogin\FilamentPasswordlessLoginPlugin;
    
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugin(FilamentPasswordlessLoginPlugin::make());
    }
    

First Use Case

Replace your default Filament login page with a magic link login:

FilamentPasswordlessLoginPlugin::make()
    ->loginPage(); // Enables magic link login by default

Visit /admin/login (or your panel's login path) to see the magic link login form.


Implementation Patterns

Core Workflow

  1. Magic Link Login Page:

    • Replace Filament's default login with a single email field.
    • On submission, send a magic link via email and redirect to a confirmation page.
    • Configure via:
      FilamentPasswordlessLoginPlugin::make()
          ->loginPage()
          ->redirectUrl('/admin/dashboard');
      
  2. Login Action Integration:

    • Add a reusable SendMagicLinkAction to any Filament page or table.
    • Example in a page header:
      protected function getHeaderActions(): array
      {
          return [
              SendMagicLinkAction::make()
                  ->slideover()
                  ->icon('heroicon-m-sparkles'),
          ];
      }
      
  3. Token Management:

    • Access a dedicated Filament resource for managing magic links:
      FilamentPasswordlessLoginPlugin::make()
          ->resource()
          ->canCreateTokens()
          ->canDeleteTokens();
      
    • Navigate to /admin/magic-links (or your custom slug) to view, generate, or invalidate tokens.
  4. Customization:

    • Override the default login page:
      FilamentPasswordlessLoginPlugin::make()
          ->login(MyCustomLoginPage::class);
      
    • Customize the action appearance:
      SendMagicLinkAction::make()
          ->icon('heroicon-m-envelope')
          ->color('success');
      

Integration Tips

  • Multi-panel Support: Each panel auto-detects its own redirect URLs. Override per-panel if needed:

    FilamentPasswordlessLoginPlugin::make()
        ->redirectUrl('/app/dashboard'); // For the 'app' panel
    
  • Standalone Actions: Use SendMagicLinkAction in table rows or forms:

    use SpykApp\FilamentPasswordlessLogin\Actions\SendMagicLinkAction;
    
    MyResource::make()
        ->columns([
            Tables\Columns\TextColumn::make('name'),
            Tables\Columns\ActionColumn::make('actions')
                ->actions([
                    SendMagicLinkAction::make(),
                ]),
        ]);
    
  • Email Customization: Replace the default mailable or notification:

    FilamentPasswordlessLoginPlugin::make()
        ->mailable(\App\Mail\CustomMagicLinkMail::class);
    
  • Widgets: Enable or disable resource page widgets:

    FilamentPasswordlessLoginPlugin::make()
        ->statsWidget()
        ->chartsWidget(false);
    

Gotchas and Tips

Pitfalls

  1. Missing Migrations:

    • Forgetting to run php artisan migrate after publishing migrations will cause errors when generating tokens.
    • Fix: Run php artisan passwordless-login:upgrade if upgrading from an older version.
  2. Token Table Mismatch:

    • The plugin expects a passwordless_login_tokens table by default. If you renamed it in config, ensure the plugin is configured to use the correct table name.
    • Fix: Check config/passwordless-login.php for table_name.
  3. Caching Issues:

    • Filament caches panel configurations. After changing plugin settings, clear the cache:
      php artisan filament:cache-reset
      
  4. Redirect URL Conflicts:

    • If redirectUrl is not set, the plugin auto-detects from the Filament panel. Ensure your panel’s path() is correctly configured.
    • Fix: Explicitly set ->redirectUrl() if auto-detection fails.
  5. Action Position Overrides:

    • If loginActionPosition is not set, the action defaults to disabled. Always specify a position:
      ->loginActionPosition(FilamentPasswordlessLoginActionPosition::EmailFieldHint)
      

Debugging

  • Token Not Sending:

    • Check if the HasMagicLogin trait is added to your User model.
    • Verify the mail driver is configured in .env (e.g., MAIL_MAILER=smtp).
    • Test with php artisan queue:work if using queues.
  • Expired Links:

    • Default token expiry is 15 minutes (configurable in passwordless-login.php).
    • Fix: Extend token_expiry_minutes or regenerate the token via the resource page.
  • Action Not Showing:

    • Ensure ->loginAction() is called and a position is set.
    • Check for JavaScript errors in browser console if using slide-over modals.

Extension Points

  1. Custom Login Page: Extend SpykApp\FilamentPasswordlessLogin\Pages\MagicLinkLogin to override UI:

    class CustomLogin extends MagicLinkLogin {
        public function getHeading(): string {
            return 'Secure Sign-In';
        }
    }
    

    Register it:

    FilamentPasswordlessLoginPlugin::make()
        ->login(CustomLogin::class);
    
  2. Custom Mailable/Notification: Replace the default email template:

    FilamentPasswordlessLoginPlugin::make()
        ->mailable(\App\Mail\CustomMagicLink::class);
    

    Ensure your mailable extends SpykApp\PasswordlessLogin\Mail\MagicLinkMail.

  3. Token Events: Listen to token events (e.g., TokenCreated) for custom logic:

    use SpykApp\PasswordlessLogin\Events\TokenCreated;
    
    TokenCreated::subscribe(function (TokenCreated $event) {
        // Custom logic (e.g., log token creation)
    });
    
  4. Slide-Over Modal: Customize the modal appearance by publishing and overriding the Blade template:

    php artisan vendor:publish --tag=filament-passwordless-login-views
    

    Edit resources/views/vendor/filament-passwordless-login/slideover.blade.php.

Configuration Quirks

  • Priority Order: Plugin fluent API settings override config file settings, which override language file defaults. Example:

    // Fluent API (highest priority)
    FilamentPasswordlessLoginPlugin::make()
        ->loginActionIcon('heroicon-m-envelope');
    
    // Config file (lower priority)
    'login_action' => [
        'icon' => 'heroicon-m-link',
    ];
    
  • Multi-Language: Language files are published separately. Override translations in resources/lang/{locale}/filament-passwordless-login.php.

  • Resource Visibility: The token resource is enabled by default. Disable it if unused:

    FilamentPasswordlessLoginPlugin::make()
        ->resource(false);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai