Skip to content

Commit 9c4b27f

Browse files
committed
fix[db]: fix logging for verification code on signup in dev mode
1 parent b10a590 commit 9c4b27f

File tree

5 files changed

+16
-291
lines changed

5 files changed

+16
-291
lines changed

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ services:
1717
- POSTGRES_URL=postgresql://postgres:postgres@db:5432/simstudio
1818
- BETTER_AUTH_URL=http://localhost:3000
1919
- NEXT_PUBLIC_APP_URL=http://localhost:3000
20-
- NEXT_PUBLIC_DISABLE_AUTH=true
2120
depends_on:
2221
- db
2322
command: npm run dev

sim/.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ DATABASE_URL="postgresql://postgres:password@localhost:5432/postgres"
44
# Authentication (Required)
55
BETTER_AUTH_SECRET=your_secret_key # Use `openssl rand -hex 32` to generate, or visit https://www.better-auth.com/docs/installation
66
BETTER_AUTH_URL=http://localhost:3000
7-
# NEXT_PUBLIC_DISABLE_AUTH=true # Uncomment to disable authentication for local development
87

98
# Email Provider (Optional)
109
# RESEND_API_KEY= # Uncomment and add your key from https://resend.com to send actual emails
@@ -14,4 +13,4 @@ BETTER_AUTH_URL=http://localhost:3000
1413
NEXT_PUBLIC_APP_URL=http://localhost:3000
1514

1615
# StackBlitz (Webcontainer) API Key (Optional, for handling sandboxed code execution for functions/custom-tools)
17-
WEBCONTAINER_CLIENT_ID=your_webcontainer_client_id
16+
# WEBCONTAINER_CLIENT_ID= # Uncomment and add your key from https://stackblitz.com/docs/webcontainer-api#webcontainer-client-id

sim/app/lib/auth.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ const resend =
1717
? new Resend(process.env.RESEND_API_KEY)
1818
: {
1919
emails: {
20-
send: async (...args: any[]) => logger.info('Email sent:', args),
20+
send: async (...args: any[]) => {
21+
logger.info('Email would have been sent in production. Details:', args)
22+
return { id: 'local-dev-mode' }
23+
},
2124
},
2225
}
2326

@@ -91,6 +94,17 @@ export const auth = betterAuth({
9194
throw new Error('Email is required')
9295
}
9396

97+
// In development with no RESEND_API_KEY, log verification code
98+
if (!process.env.RESEND_API_KEY || process.env.RESEND_API_KEY.trim() === '') {
99+
logger.info('🔑 VERIFICATION CODE FOR LOGIN/SIGNUP', {
100+
email: data.email,
101+
otp: data.otp,
102+
type: data.type,
103+
})
104+
return
105+
}
106+
107+
// In production, send an actual email
94108
const result = await resend.emails.send({
95109
from: 'Sim Studio <onboarding@simstudio.ai>',
96110
to: data.email,
@@ -111,7 +125,6 @@ export const auth = betterAuth({
111125
logger.error('Error sending verification code:', {
112126
error,
113127
email: data.email,
114-
otp: data.otp,
115128
})
116129
throw error
117130
}

sim/app/scripts/build-standalone.js

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

sim/middleware.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ export async function middleware(request: NextRequest) {
77
return NextResponse.redirect(new URL('/w/1', request.url))
88
}
99

10-
// Skip auth check if DISABLE_AUTH is set (for standalone mode)
11-
if (process.env.DISABLE_AUTH === 'true' || process.env.NEXT_PUBLIC_DISABLE_AUTH === 'true') {
12-
return NextResponse.next()
13-
}
14-
1510
const sessionCookie = getSessionCookie(request)
1611
if (!sessionCookie) {
1712
return NextResponse.redirect(new URL('/login', request.url))

0 commit comments

Comments
 (0)