Skip to content

Commit 5dfefa1

Browse files
committed
cleanup: squash migrations, indentation, custom_domain_logger env var
1 parent c9942fb commit 5dfefa1

File tree

7 files changed

+42
-33
lines changed

7 files changed

+42
-33
lines changed

.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,5 @@ NEXT_TELEMETRY_DISABLED=1
195195
# DNS resolver for custom domain verification
196196
DNS_RESOLVER=1.1.1.1
197197

198-
# domain debug
199-
DOMAIN_DEBUG=true
198+
# domain debug logger
199+
CUSTOM_DOMAIN_LOGGER=false

components/territory-domains.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ export const DomainProvider = ({ customDomain: ssrCustomDomain, children }) => {
3636
// temporary auth sync
3737
useEffect(() => {
3838
if (router.query.type === 'sync') {
39-
console.log('signing in with sync')
40-
signIn('sync', { token: router.query.token, callbackUrl: router.query.callbackUrl, multiAuth: router.query.multiAuth, redirect: false })
39+
console.log('signing in with sync', router.query)
40+
signIn('sync', {
41+
token: router.query.token,
42+
multiAuth: router.query.multiAuth,
43+
redirect: false
44+
})
4145
router.push(router.query.callbackUrl) // next auth redirect only supports the main domain
4246
}
4347
}, [router.query.type])

lib/domains.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cachedFetcher } from '@/lib/fetch'
22

33
export const domainLogger = () => {
4-
if (process.env.DOMAIN_DEBUG === 'true') {
4+
if (process.env.CUSTOM_DOMAIN_LOGGER === 'true') {
55
return {
66
log: (message, ...args) => {
77
console.log(message, ...args)
@@ -10,6 +10,11 @@ export const domainLogger = () => {
1010
console.error(message, ...args)
1111
}
1212
}
13+
} else {
14+
return {
15+
log: () => {},
16+
error: () => {}
17+
}
1318
}
1419
}
1520

pages/api/auth/sync.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default async function handler (req, res) {
1414
let customDomain
1515
try {
1616
customDomain = new URL(decodedRedirectUrl)
17+
// not cached because we're handling sensitive data
1718
const domain = await models.customDomain.findUnique({ where: { domain: customDomain.host, status: 'ACTIVE' } })
1819
if (!domain) {
1920
return res.status(400).json({ status: 'ERROR', reason: 'custom domain not found' })

pages/login.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ export async function getServerSideProps ({ req, res, query: { callbackUrl, mult
7070
}
7171

7272
function LoginFooter ({ callbackUrl, multiAuth }) {
73-
const query = {
74-
callbackUrl
75-
}
76-
if (multiAuth) { // multiAuth can be optional
73+
const query = { callbackUrl }
74+
if (multiAuth) {
7775
query.multiAuth = multiAuth
7876
}
7977
return (

prisma/migrations/20250304121322_custom_domains/migration.sql

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- CreateTable
1+
-- Custom Domain
22
CREATE TABLE "CustomDomain" (
33
"id" SERIAL NOT NULL,
44
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -42,3 +42,27 @@ CREATE INDEX "CustomDomain_created_at_idx" ON "CustomDomain"("created_at");
4242

4343
-- AddForeignKey
4444
ALTER TABLE "CustomDomain" ADD CONSTRAINT "CustomDomain_subName_fkey" FOREIGN KEY ("subName") REFERENCES "Sub"("name") ON DELETE CASCADE ON UPDATE CASCADE;
45+
46+
-- Custom Branding
47+
CREATE TABLE "CustomBranding" (
48+
"id" SERIAL NOT NULL,
49+
"title" TEXT,
50+
"colors" JSONB DEFAULT '{}',
51+
"logoId" INTEGER,
52+
"faviconId" INTEGER,
53+
"subName" CITEXT NOT NULL,
54+
55+
CONSTRAINT "CustomBranding_pkey" PRIMARY KEY ("id")
56+
);
57+
58+
-- CreateIndex
59+
CREATE UNIQUE INDEX "CustomBranding_subName_key" ON "CustomBranding"("subName");
60+
61+
-- AddForeignKey
62+
ALTER TABLE "CustomBranding" ADD CONSTRAINT "CustomBranding_logoId_fkey" FOREIGN KEY ("logoId") REFERENCES "Upload"("id") ON DELETE SET NULL ON UPDATE CASCADE;
63+
64+
-- AddForeignKey
65+
ALTER TABLE "CustomBranding" ADD CONSTRAINT "CustomBranding_faviconId_fkey" FOREIGN KEY ("faviconId") REFERENCES "Upload"("id") ON DELETE SET NULL ON UPDATE CASCADE;
66+
67+
-- AddForeignKey
68+
ALTER TABLE "CustomBranding" ADD CONSTRAINT "CustomBranding_subName_fkey" FOREIGN KEY ("subName") REFERENCES "Sub"("name") ON DELETE CASCADE ON UPDATE CASCADE;

prisma/migrations/20250402003413_custom_brandings/migration.sql

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

0 commit comments

Comments
 (0)