laravel-magiclink icon indicating copy to clipboard operation
laravel-magiclink copied to clipboard

Call to a member function run() on null

Open LarryBarker opened this issue 6 months ago • 4 comments

We've been seeing this error more frequently which seems to happen when a user tries to use a magic link with an invalid token. We send magic links in an onboarding email to allow users access to complete their profile, and we think users are going back to this email and using the link to try and login again.

I've tracked this back to the getMagicLinkByToken method on the MagicLink class: https://github.com/cesargb/laravel-magiclink/blob/225c3c289ec68a66c9f93761accee132744ab85c/src/MagicLink.php#L187

In our case, this is returning null for whatever reason, and then when the MagicLinkController tries to call run(), its calling it on null and throwing the exception.

Do you have any ideas on how we can work around this? Ideally, if someone visits a link where the token is invalid, we could show them a page with more information and maybe a form to resend a magic link (we would implement this ourselves if possible)?

Thank you for taking time to share this package - it has been very helpful in getting our onboarding flow figured out. Any and all feedback is appreciated, and thank you again 🙏

LarryBarker avatar Dec 11 '23 18:12 LarryBarker