Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): unstick /connect after in-modal sign-in by redirecting to the authorize endpoint #5133

MergedTorbenWetter(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/5133/headmerged by juliusmarminge View on GitHub

Showing 5 changed files with 45 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
24 additions and 0 deletionsapps/web/src/cloud/connectCliAuth.test.tsModified
View file
@@ -2,6 +2,7 @@
​
import {
buildConnectCliClerkAuthorizeUrl,
+ connectCliSignInRedirectUrl,
hasConnectCliAuthConfig,
readConnectCliCallbackResult,
} from "./connectCliAuth";
@@ -69,6 +70,29 @@
).toBeNull();
});
​
+ it("sends the sign-in redirect to the authorize endpoint, not back to /connect", () => {
+ vi.stubEnv("VITE_CLERK_PUBLISHABLE_KEY", TEST_PUBLISHABLE_KEY);
+ vi.stubEnv("VITE_CLERK_CLI_OAUTH_CLIENT_ID", "oauthapp_123");
+​
+ const connectUrl = "https://app.t3.codes/connect#state=state-1&challenge=challenge-1";
+ const redirectUrl = connectCliSignInRedirectUrl(
+ { state: "state-1", challenge: "challenge-1" },
+ connectUrl,
+ );
+​
+ expect(redirectUrl).not.toBe(connectUrl);
+ expect(new URL(redirectUrl).pathname).toBe("/oauth/authorize");
+ });
+​
+ it("falls back to the current URL when the authorize URL cannot be built", () => {
+ vi.stubEnv("VITE_CLERK_PUBLISHABLE_KEY", TEST_PUBLISHABLE_KEY);
+​