Skip to content

Commit

Permalink
fix(web): Restore broken Github sign-in
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros committed Jun 3, 2024
1 parent 119baea commit 8b39c77
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions apps/web/src/pages/auth/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface LocationState {

export function LoginForm({ email, invitationToken }: LoginFormProps) {
const segment = useSegment();
const { login, currentUser } = useAuth();
const { login, currentUser, organizationId, environmentId } = useAuth();
const { startVercelSetup } = useVercelIntegration();
const { isFromVercel, params: vercelParams } = useVercelParams();
const [params] = useSearchParams();
Expand All @@ -48,31 +48,39 @@ export function LoginForm({ email, invitationToken }: LoginFormProps) {
>((data) => api.post('/v1/auth/login', data));

useEffect(() => {
async () => {
if (tokenInQuery) {
await login(tokenInQuery);
(async () => {
if (!tokenInQuery) {
return;
}

if (isFromVercel) {
startVercelSetup();
if (!invitationToken && (!organizationId || !environmentId)) {
await login(tokenInQuery, ROUTES.AUTH_APPLICATION);

return;
}
return;
}

if (source === 'cli') {
segment.track('Dashboard Visit', {
widget: sourceWidget || 'unknown',
source: 'cli',
});
navigate(ROUTES.GET_STARTED);
if (isFromVercel) {
await login(tokenInQuery);
startVercelSetup();

return;
}
return;
}

if (source === 'cli') {
segment.track('Dashboard Visit', {
widget: sourceWidget || 'unknown',
source: 'cli',
});
await login(tokenInQuery, ROUTES.GET_STARTED);

navigate(ROUTES.WORKFLOWS);
return;
}
};

await login(tokenInQuery);
navigate(ROUTES.WORKFLOWS);
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [login, navigate, currentUser, tokenInQuery, segment]);
}, [login, navigate, currentUser, tokenInQuery, segment, organizationId, environmentId]);

const signupLink = isFromVercel ? `${ROUTES.AUTH_SIGNUP}?${params.toString()}` : ROUTES.AUTH_SIGNUP;
const resetPasswordLink = isFromVercel
Expand Down

0 comments on commit 8b39c77

Please sign in to comment.