cesargb / laravel-magiclink

Create link for authenticate in Laravel without password or get private content
MIT License
347 stars 42 forks source link

Possible to set "remember me"? #93

Closed Laupet closed 1 year ago

Laupet commented 1 year ago

Great package you have made! Thanks.

Is it possible in any way to set "remember me" for the login action? I want the login session to last longer than the global SESSION_LIFETIME that is defined in .env.

cesargb commented 1 year ago

Thanks! In this moment, you only can make a CustomAction, example:

use MagicLink\Actions\ActionAbstract;

class LoginWithRememberAction extends ActionAbstract
{
    public function __construct(public int $userId)
    {
    }

    public function run()
    {
        Auth::loginUsingId($this->id, true);

        return parent::run();
    }
}

But this feature will be interesting add in the LoginAction, please, give me a few days to pull this request or, if you wish, you can send a PR.

cesargb commented 1 year ago

This feature has been released in version v2.16.0

$action = new LoginAction(User::first());
$action->remember();

$urlShowView = MagicLink::create($action)->url;
Laupet commented 1 year ago

Perfect, thanks alot. Already implemented the changes from 2.16. Works like a charm!