{"id":32610541,"url":"https://github.com/maize-tech/laravel-magic-login","last_synced_at":"2025-10-30T13:50:22.944Z","repository":{"id":65471367,"uuid":"575455140","full_name":"maize-tech/laravel-magic-login","owner":"maize-tech","description":"Easily add passwordless authentication into your application","archived":false,"fork":false,"pushed_at":"2025-06-24T11:50:13.000Z","size":148,"stargazers_count":159,"open_issues_count":0,"forks_count":16,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-24T12:47:18.979Z","etag":null,"topics":["authentication","laravel","login","magic-auth","magic-login","passwordless"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maize-tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"maize-tech"}},"created_at":"2022-12-07T14:52:33.000Z","updated_at":"2025-06-24T11:50:17.000Z","dependencies_parsed_at":"2024-03-11T09:55:51.434Z","dependency_job_id":"27f37afd-6e86-40b3-8506-871c19446beb","html_url":"https://github.com/maize-tech/laravel-magic-login","commit_stats":{"total_commits":27,"total_committers":4,"mean_commits":6.75,"dds":"0.40740740740740744","last_synced_commit":"213ed68c6692ee6633c9600423b8919fcd6fe102"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/maize-tech/laravel-magic-login","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-magic-login","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-magic-login/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-magic-login/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-magic-login/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maize-tech","download_url":"https://codeload.github.com/maize-tech/laravel-magic-login/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maize-tech%2Flaravel-magic-login/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281818074,"owners_count":26566858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","laravel","login","magic-auth","magic-login","passwordless"],"created_at":"2025-10-30T13:50:21.844Z","updated_at":"2025-10-30T13:50:22.938Z","avatar_url":"https://github.com/maize-tech.png","language":"PHP","funding_links":["https://github.com/sponsors/maize-tech"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/art/socialcard-dark.png\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"/art/socialcard-light.png\"\u003e\n  \u003cimg src=\"/art/socialcard-light.png\" alt=\"Social Card of Laravel Magic Login\"\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\n# Laravel Magic Login\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/maize-tech/laravel-magic-login.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-magic-login)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-magic-login/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/maize-tech/laravel-magic-login/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/maize-tech/laravel-magic-login/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/maize-tech/laravel-magic-login/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/maize-tech/laravel-magic-login.svg?style=flat-square)](https://packagist.org/packages/maize-tech/laravel-magic-login)\n\nEasily add passwordless authentication into your application.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require maize-tech/laravel-magic-login\n```\n\nYou can publish the config and migration files and run the migrations with:\n\n```bash\nphp artisan magic-login:install\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Magic Login model\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the fully qualified class name of the magic login\n    | model.\n    | By default, the value is Maize\\MagicLogin\\Models\\MagicLogin::class\n    |\n    */\n\n    'model' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Expiration time\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the amount of minutes before the magic login link\n    | expires.\n    | By default, the value is 120 minutes (2 hours).\n    |\n    */\n\n    'expiration' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Authentication guard\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the guard you want to use to authenticate the user.\n    | The guard name must be defined in your application's auth.php config file.\n    | By default, the value is 'web'.\n    |\n    */\n\n    'guard' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Default redirect url\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the redirect url used by default if none is specified\n    | when creating the magic link.\n    |\n    */\n\n    'redirect_url' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Exception class\n    |--------------------------------------------------------------------------\n    |\n    | Here you may specify the default exception class used for all package\n    | related exceptions.\n    | Useful if you need to customize the http status code in case an exception\n    | is thrown during the magic login process.\n    | By default, the value is Illuminate\\Routing\\Exceptions\\InvalidSignatureException::class\n    |\n    */\n\n    'exception' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Force single link\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify whether a user can only have one valid magic link\n    | at a time or not.\n    | If true, when you generate a new magic link for a specific user all\n    | previously generated links will be revoked.\n    | By default, the value is true.\n    |\n    */\n\n    'force_single' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Logins limit\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify the amount of logins a user can perform with the\n    | same magic link.\n    | Can be either -1, which lets the user login indefinitely, or any number\n    | greater than or equal to 1.\n    | By default, the value is -1.\n    |\n    */\n\n    'logins_limit' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Send Notification Action\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify the fully qualified class name of a custom action\n    | used to send the magic login email notification.\n    | By default, the value is Maize\\MagicLogin\\Actions\\SendMagicLinkAction::class\n    */\n\n    'send_notification_action' =\u003e null,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Notification class\n    |--------------------------------------------------------------------------\n    |\n    | Here you can specify the fully qualified class name of the magic link\n    | email notification.\n    | By default, the value is Maize\\MagicLogin\\Notifications\\MagicLinkNotification::class\n    */\n\n    'notification' =\u003e null,\n\n    'route' =\u003e [\n\n        /*\n        |--------------------------------------------------------------------------\n        | Route method\n        |--------------------------------------------------------------------------\n        |\n        | Here you may specify the route's allowed methods.\n        | By default, the value is 'GET'.\n        |\n        */\n\n        'methods' =\u003e null,\n\n        /*\n        |--------------------------------------------------------------------------\n        | Route URI\n        |--------------------------------------------------------------------------\n        |\n        | Here you may specify the route's uri.\n        | By default, the value is 'magic-login'.\n        |\n        */\n\n        'uri' =\u003e null,\n\n        /*\n        |--------------------------------------------------------------------------\n        | Route name\n        |--------------------------------------------------------------------------\n        |\n        | Here you may specify the route's name.\n        | By default, the value is 'magic-login'.\n        |\n        */\n\n        'name' =\u003e null,\n\n        /*\n        |--------------------------------------------------------------------------\n        | Route controller\n        |--------------------------------------------------------------------------\n        |\n        | Here you may specify the fully qualified class name of a custom controller\n        | class used to handle the magic login request.\n        | By default, the value is Maize\\MagicLogin\\Http\\Controllers\\MagicLoginController::class.\n        |\n        */\n\n        'controller' =\u003e null,\n\n        /*\n        |--------------------------------------------------------------------------\n        | Route middlewares\n        |--------------------------------------------------------------------------\n        |\n        | Here you may specify the list of middlewares used by the magic login route.\n        | By default, the value is Maize\\MagicLogin\\Http\\Middleware\\ValidateSignature::class.\n        |\n        */\n\n        'middleware' =\u003e null,\n\n    ],\n\n];\n```\n\n## Usage\n\n### Basic\n\nTo use the package, all you have to do is include the magic link route in your routes file.\nBy default, you should include it under `routes/web.php`:\n\n``` php\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\nMagicLink::route();\n```\n\nThat's it!\nOnce done, you can already generate an invitation link to any model extending the `Authenticatable` class using the `make` method:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::make(\n    authenticatable: $user\n);\n```\n\n### Email notifications\n\n#### Send an email notification\n\nOptionally, you may also automatically send an email notification to the given user using the `send` method:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user\n);\n```\n\nwhich is equals to using the `make` method with the `notify` parameter set to `true`:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::make(\n    authenticatable: $user,\n    notify: true\n);\n```\n\n#### Customize the notification class\n\nWhen needed, you can customize the email notification.\nAll you have to do is create your own notification and override the default `MagicLinkNotification` class:\n\n``` php\nuse Illuminate\\Notifications\\Messages\\MailMessage;\nuse Maize\\MagicLogin\\Notifications\\MagicLinkNotification as BaseMagicLinkNotification;\n\nclass MagicLinkNotification extends BaseMagicLinkNotification\n{\n    public function toMail($notifiable): MailMessage\n    {\n        return (new MailMessage)\n            -\u003eline(__('This is my custom magic link notification message'))\n            -\u003eaction(__('Join now'), $this-\u003euri);\n    }\n}\n```\n\nFinally, you can update the `notification` attribute under `config/magic-login.php` with the new class path.\n\n### Force single link\n\nWhen enabled, users can only have one valid link at a time.\nThis means that when a new link is created, all previously created links are invalidated.\n\nTo enable this option, you can set the `force_single` attribute under `config/magic-login.php` to `true`.\n\n### Magic link generator options\n\nThe package offers many useful parameters for the `make` method to allow you customizing every single magic link:\n\n- [`Redirect url`](#redirect-url)\n- [`Expiration time`](#expiration-time)\n- [`Route name`](#route-name)\n- [`Authentication guard`](#authentication-guard)\n- [`Logins limit`](#logins-limit)\n- [`Custom metadata`](#custom-metadata)\n\n#### Redirect url\n\nYou can provide a redirect url used after authenticating the user:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    redirectUrl: 'yourapplication.test/your-path'\n);\n```\n\nWhen not provided, the default value defined in `redirect_url` attribute under `config/magic-login.php` will be used.\n\n#### Expiration time\n\nYou can define the amount of time before a magic link expires by providing a carbon instance or an integer with the amount of minutes:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    expiration: now()-\u003eaddDays(10), // the link will expire in 10 days\n);\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    expiration: 60, // the link will expire in 1 hour (60 minutes)\n);\n```\n\nWhen not provided, the default value defined in `expiration` attribute under `config/magic-login.php` will be used.\n\n#### Route name\n\nYou can define the route name used to generate the magic link:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    routeName: 'magic-link',\n);\n```\n\nWhen not provided, the default value defined in `route.name` attribute under `config/magic-login.php` will be used.\n\n#### Authentication guard\n\nYou can define the authentication guard used to authenticate the user:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    guard: 'api' // the 'api' auth guard will be used\n);\n```\n\nWhen not provided, the default value defined in `guard` attribute under `config/magic-login.php` will be used.\n\n#### Logins limit\n\nYou can define the amount of times a single link can be used before expiring.\nThe value can be either -1, which lets the user login indefinitely, or any number greater than or equal to 1:\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    loginsLimit: 5 // the link can be used 5 times at max\n);\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    loginsLimit: -1 // the link can be used an infinite amount of times\n);\n```\n\nWhen not provided, the default value defined in `logins_limit` attribute under `config/magic-login.php` will be used.\n\n#### Custom metadata\n\nOptionally, you can store custom metadata in case you need to perform custom queries.\n\n``` php\nuse App\\Models\\User;\nuse Maize\\MagicLogin\\Facades\\MagicLink;\nuse Maize\\MagicLogin\\Models\\MagicLogin;\n\n$user = User::firstOrFail();\n\n$magicLink = MagicLink::send(\n    authenticatable: $user,\n    metadata: ['test' =\u003e true]\n);\n\nMagicLogin::query()\n    -\u003ewhereJsonContains('metadata-\u003etest', true)\n    -\u003ecount(); // returns 1\n\nMagicLogin::query()\n    -\u003ewhereJsonContains('metadata-\u003etest', false)\n    -\u003ecount(); // returns 0\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/maize-tech/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](https://github.com/maize-tech/.github/security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Enrico De Lazzari](https://github.com/enricodelazzari)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-magic-login","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaize-tech%2Flaravel-magic-login","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaize-tech%2Flaravel-magic-login/lists"}