Skip to content

Commit f92f71f

Browse files
atrakhConvex, Inc.
authored andcommitted
dashboard: add UI for linking and unlinking identities (#37537)
- Adds UI on the profile page for listing, linking, and unlinking identities - Adds `/link_identity` page that orchestrates all identity linking flows - GitOrigin-RevId: 0bd84e878e97ea73a028ebb8104bcadff7468daf
1 parent 9e561c5 commit f92f71f

24 files changed

+885
-50
lines changed

npm-packages/dashboard/next.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const allowedImageDomains = [
2222
hostname: "**.convex.cloud",
2323
pathname: "/api/storage/**",
2424
},
25+
{
26+
protocol: "https",
27+
hostname: "lh3.googleusercontent.com",
28+
pathname: "**",
29+
},
2530
];
2631

2732
const securityHeaders = [
@@ -118,7 +123,12 @@ const nextConfig = {
118123
domains:
119124
process.env.VERCEL_ENV === "production"
120125
? undefined
121-
: ["127.0.0.1", "s.gravatar.com", "avatars.githubusercontent.com"],
126+
: [
127+
"127.0.0.1",
128+
"s.gravatar.com",
129+
"avatars.githubusercontent.com",
130+
"lh3.googleusercontent.com",
131+
],
122132
remotePatterns: allowedImageDomains,
123133
},
124134
experimental: {

npm-packages/dashboard/src/api/api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function useBBMutation<
133133
toastOnError = true,
134134
googleAnalyticsEvent,
135135
redirectTo,
136+
includeCredentials = false,
136137
method = "post" as Method,
137138
...rest
138139
}: {
@@ -145,6 +146,7 @@ export function useBBMutation<
145146
toastOnError?: boolean;
146147
redirectTo?: string;
147148
googleAnalyticsEvent?: string;
149+
includeCredentials?: boolean;
148150
} & (
149151
| {
150152
mutateKey: M;
@@ -194,6 +196,7 @@ export function useBBMutation<
194196
params: { path: pathParams },
195197
body: body[0],
196198
headers,
199+
credentials: includeCredentials ? "include" : "omit",
197200
});
198201

199202
if (!response.ok && error) {
@@ -227,6 +230,7 @@ export function useBBMutation<
227230
authHeader,
228231
googleAnalyticsEvent,
229232
googleAnalyticsId,
233+
includeCredentials,
230234
method,
231235
mutate,
232236
path,

npm-packages/dashboard/src/api/profile.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,38 @@ export function useDeleteAccount() {
8383
toastOnError: false,
8484
});
8585
}
86+
87+
export function useListIdentities() {
88+
const { data: identities } = useBBQuery({
89+
path: "/list_identities",
90+
pathParams: undefined,
91+
});
92+
return identities;
93+
}
94+
95+
export function useSetLinkIdentityCookie() {
96+
return useBBMutation({
97+
path: "/set_jwt_cookie",
98+
pathParams: undefined,
99+
includeCredentials: true,
100+
});
101+
}
102+
103+
export function useLinkIdentity() {
104+
return useBBMutation({
105+
path: "/link_identity",
106+
pathParams: undefined,
107+
mutateKey: "/list_identities",
108+
includeCredentials: true,
109+
});
110+
}
111+
112+
export function useUnlinkIdentity() {
113+
return useBBMutation({
114+
path: "/unlink_identity",
115+
pathParams: undefined,
116+
mutateKey: "/list_identities",
117+
successToast: "Identity removed.",
118+
redirectTo: "/api/auth/logout",
119+
});
120+
}

npm-packages/dashboard/src/components/login/LoginPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useState } from "react";
33
import { Spinner } from "@ui/Spinner";
44
import { buttonClasses } from "@ui/Button";
55

6-
import GithubLogo from "./logos/github-logo.svg";
6+
import GithubLogo from "logos/github-logo.svg";
77

88
export function LoginPage({ returnTo }: { returnTo?: string }) {
99
const [isLoggingIn, setIsLoggingIn] = useState(false);

npm-packages/dashboard/src/components/login/VHSLoginPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import classNames from "classnames";
33
import { useState } from "react";
44
import Logo from "images/convex-light.svg";
55
import { GoogleAnalytics } from "elements/GoogleAnalytics";
6+
import GithubLogo from "logos/github-logo.svg";
67
import loginBackground from "../../../public/vhs-bg.png";
78
import loading from "../../../public/vhs-loading.gif";
8-
import GithubLogo from "./logos/github-logo.svg";
99

1010
export function VHSLoginPage({ returnTo }: { returnTo?: string }) {
1111
const [isLoggingIn, setIsLoggingIn] = useState(false);

npm-packages/dashboard/src/components/login/logos/bitbucket.svg

Lines changed: 0 additions & 10 deletions
This file was deleted.

npm-packages/dashboard/src/components/login/logos/gitlab.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)