Skip to content

Commit 532cb57

Browse files
committed
Update backfill-saml-sso.ts
1 parent 3c86c6f commit 532cb57

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

apps/web/scripts/migrations/backfill-saml-sso.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isGenericEmail } from "@/lib/is-generic-email";
12
import { prisma } from "@dub/prisma";
23
import "dotenv-flow/config";
34

@@ -36,8 +37,10 @@ async function main() {
3637
const email = workspace.users[0]?.user?.email;
3738
const emailDomain = email ? email.split("@")[1]?.toLowerCase() : undefined;
3839

39-
if (!emailDomain) {
40-
console.log(`Workspace ${workspace.name} has no email domain`);
40+
if (!emailDomain || (email && isGenericEmail(email))) {
41+
console.log(
42+
`Workspace ${workspace.name}'s email domain (${emailDomain}) is invalid or generic, skipping...`,
43+
);
4144
continue;
4245
}
4346

@@ -50,18 +53,18 @@ async function main() {
5053

5154
console.table(workspacesToUpdate);
5255

53-
// await Promise.allSettled(
54-
// workspacesToUpdate.map((workspace) =>
55-
// prisma.project.update({
56-
// where: {
57-
// id: workspace.id,
58-
// },
59-
// data: {
60-
// ssoEmailDomain: workspace.ssoEmailDomain,
61-
// },
62-
// }),
63-
// ),
64-
// );
56+
await Promise.allSettled(
57+
workspacesToUpdate.map((workspace) =>
58+
prisma.project.update({
59+
where: {
60+
id: workspace.id,
61+
},
62+
data: {
63+
ssoEmailDomain: workspace.ssoEmailDomain,
64+
},
65+
}),
66+
),
67+
);
6568
}
6669

6770
main();

0 commit comments

Comments
 (0)