Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send magic link without API call? #35

Open
neilrackett opened this issue Nov 3, 2023 · 3 comments
Open

Send magic link without API call? #35

neilrackett opened this issue Nov 3, 2023 · 3 comments

Comments

@neilrackett
Copy link

Thank you for your great work on this strategy!

Is there an existing way to send or generate a magic link using just JavaScript, without needing to do it via a POST/GET call (which the current send() method is specifically designed to do)?

It would be great to be able to send or generate magic links from within a custom API endpoint, for example:

  • magicLogin.send('foo@bar.com') to send an email notification to a user telling them that a document is available that included a magic link that takes them straight to it; or
  • magicLogin.getMagicLink('foo@bar.com') to generate a magic link URL to be used elsewhere
@adrianbienias
Copy link

I'd love to have that possibility too.
Any chance you found a solution for this?

@neilrackett
Copy link
Author

neilrackett commented Jul 29, 2024

@adrianbienias I've implemented a solution to this by adding a new create method to the MagicLoginStrategy class that returns the same href and code values that are currently passed to your custom sendMagicLink method, for example:

const { href, code } = magicLogin.create('my.email@foo.com');
console.log(`Magic link is ${href} and verification code is ${code}`);

I've created a pull request, but in the meantime you're welcome to use my fork:

npm i github:neilrackett/passport-magic-login

@adrianbienias
Copy link

@neilrackett, thanks for sharing your solution.
I've also ended up with crafting custom solution (ultimately even using total own implementation instead of passport-magic-login).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants