-
Notifications
You must be signed in to change notification settings - Fork 140
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
feat: adding delay after OTP code validation #1288
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd the label graphite-merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's goin on here? This seems a bit of a smell for a couple reasons:
- having a delay implies that there's some async state that we are waiting to be resolved (and 3 seconds seems high)
- If this is something that should be happening for all users of the UI components, then having it live only in the ui-demo folder means that folks using the auth card in an embedded setting would have to do the same thing here which doesn't seem very intuitive.
I think I'm missing some context on what was happening before we introduced the delay, what's the intention behind this and the original change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this file a bit... seems like a few things are at play potentially.
If calling authenticate
with the OTP code is hitting both onSuccess
and isConnected == true
then that should be a logged in user. If the user is not logged in, then isConnected
shouldn't be true and should likely still be in an authenticating state (similar to how magic link used to be in an email_authenticating
state). I imagine the signer would similarly be in an email_awaiting_otp
state and once authenticate
returns successfully, it should update the SignerStatus
to complete
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just tried it out on a local branch with the delay removed altogether and seems to work without issue, so this might actually just be me missing context. Is this is a it's "too fast" situation?
@moldy530 I should have add some context, sorry about that. |
That's super helpful context, thanks @jcaleb4!! Lemme think about the sessionType thing a little because I'm not 100% on it, but seems it's probably fine |
so one thing you could do in the could be worth timeboxing. my only motivation for doing that is that this PR does a good job of isolating behaviour and interfaces that are ui-demo specific, and if we can truly isolate this logic without adding stuff to the core |
I can take a look at that approach, I did try several ways but some of them were inconsistent when reloading after the user is already authenticated and some other problems, but I can retake a look to see if I can make it work without adding a new method into the signer |
@moldy530 I did some refactors, turns out we don't even need the usePrevious hook, and now the delay lives only in the Thank you for the feedback! I feel a lot better with this implementation :) |
Gotcha, can we confirm with Will and Julia that 3 seconds is an acceptable delay to apply globally? I don't want devs to end up feeling like this is too slow in the future. Maybe 250-500ms is better as that's a typical range for animations |
Co-authored-by: Michael Moldoveanu <[email protected]>
Pull Request Checklist
yarn test
)site
folder, and guidelines for updating/adding docs can be found in the contribution guide)feat!: breaking change
)yarn lint:check
) and fix any issues? (yarn lint:write
)Using the discord branch just to test other login methods working along:
https://www.loom.com/share/02f6b5b3928a4b6a9a543aeb96d21ab3?sid=fb440839-b3ce-4fe7-bee8-4e87bfeb0dd5
PR-Codex overview
This PR introduces the
useAuthContext
hook for managing authentication context in the application, updates theLoadingOtp
component's delay, and enhances theAuthCardWrapper
component to utilize the new hook for better user authentication handling.Detailed summary
useAuthContext
export inindex.ts
.useAuthContext
documentation inuseAuthContext.mdx
.AUTH_DELAY
from 3000ms to 1000ms inotp.tsx
.setAuthStep
inLoadingOtp
.useAuthContext
inAuthCardWrapper
for managing authentication state.RenderContent
to show/hide the authentication card based on user andauthStep
.