pownall / laravel-magic-login
Passwordless login for Laravel. Allows users to login via a magic link.
Requires
- php: ^7.4|^8.0
- illuminate/support: ^7.0|^8.0
- spatie/url: ^1.3.5
Requires (Dev)
- laravel/legacy-factories: ^1.1
- mockery/mockery: ^1.4
- orchestra/testbench: ^5.0|^6.0
- phpunit/phpunit: ^9.3
- vimeo/psalm: ^4.2
This package is auto-updated.
Last update: 2024-08-29 05:49:48 UTC
README
Allows you to create a temporary signed route that logs a user in. There is no config file, you define everything when generating the url.
I see the general usage being
User requests login
-> You generate link and send in email
-> User clicks link and is signed in
.
Installation
You can install the package via composer:
composer require pownall/magic-login
Available Methods
redirectToUrl(string $url)
- Default is/
.expiresAt(CarbonInterface $pointInTime)
- Default is1 hour
after generating link.
Usage
Simple usage is:
MagicLogin::forUser($user)->generate();
If you want to alter the redirect url:
MagicLogin::forUser($user) ->redirectToUrl('/somewhere-else') ->generate();
or
MagicLogin::forUser($user) ->redirectToUrl(route('admin.dashboard')) ->generate();
If you want to make the link expire earlier or later pass a CarbonInterface
to the expireAt
method.
MagicLogin::forUser($user) ->expireAt(Carbon::now()->addMinutes(30)) ->generate();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email pownall@hey.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.