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

passwordless.CreateMagicLinkByEmail doesn't pass along response.OK.CodeLifetime #428

Open
gwd opened this issue Sep 23, 2024 · 3 comments
Open

Comments

@gwd
Copy link

gwd commented Sep 23, 2024

When overriding a hook for sending an email as part of the auth workflow, not only the link but also the lifetime of the link is provided, allowing the email (or whatever presentation) to tell the user how long to expect the link to work.

However, when creating a link outside of the normal auth flow with CreateMagicLinkByEmail, the CodeLifetime is discarded, meaning it's impossible (without making assumptions) to tell the user how long the lifetime will last.

@rishabhpoddar
Copy link
Contributor

That is true, however, the lifetime is statically defined in the core config anyway, so the golang code can use the same value (though yea, you would be repeating that value in two places, which is not ideal).

We can change this func to return the link and the lifetime, however, this will be a low priority task for us.

@gwd
Copy link
Author

gwd commented Sep 24, 2024

Low priority for sure. I wouldn't mind sending you a PR if I had an idea the approach you wanted to take -- whether to change the function signature of CreateMagicLinkByEmail (a breaking change -- technically OK in a pre-1.0 library, but still not something to do lightly), or introduce a new function with a new signature; and whether to just return more values, or to return a structure (which could then be extended if more things were added). That would be relatively low priority for me as well. 😄

In support of the motivation: You can't really "use the same value" in both places, as it's not necessarily available in the other place. You could hard-code it based on what you know the server is set up to use (which is what I'm doing now), but that's not terribly robust: What if the default changes at some point? Or what if you add the ability to change the expiration length?

As you say, not huge priority, but definitely worth fixing to avoid little issues down the road.

Let me know if you're open to a PR, and if so, what approach you'd prefer.

@rishabhpoddar
Copy link
Contributor

We would want to change the func signature of CreateMagicLinkByEmail and other similar functions. Surely open for a PR. This would also involve a change in our docs though (wherever CreateMagicLinkByEmail is being used in it)

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