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 user back to oauth flow after login #100

Merged
merged 8 commits into from
Sep 20, 2023
15 changes: 13 additions & 2 deletions src/screens/Authentication/Verify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ interface VerifyProps {
}

export const Verify = ({ onBack, userCode, verificationUrl }: VerifyProps) => {
const [openDialog, closeDialog] = useChromaticDialog();
// Close the dialog on unmount
const [openDialog, closeDialog] = useChromaticDialog((event) => {
// If the user logs in as part of the grant process, don't close the dialog,
// instead redirect us back to where we were trying to go.
if (event.message === "login") {
openDialog(verificationUrl);
}
});

// Close the dialog on unmount, which happens automatically when poll for a token.
// Later (https://linear.app/chromaui/issue/AP-3549/onboarding-flow-for-new-users-to-create-a-project)
// we'll actually wait for the grant event and:
// - grab a token immediately
// - check if the user has projects, if not redirect to new project screen.
useEffect(() => () => closeDialog(), [closeDialog]);

return (
Expand Down
Loading