Skip to content

Commit 74be085

Browse files
committed
ack PR comments
1 parent 0b43d6f commit 74be085

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

apps/sim/app/api/auth/forget-password/route.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Forget Password API Route', () => {
7272
const data = await response.json()
7373

7474
expect(response.status).toBe(400)
75-
expect(data.message).toBe('Redirect URL must be same-origin')
75+
expect(data.message).toBe('Redirect URL must be a valid same-origin URL')
7676

7777
const auth = await import('@/lib/auth')
7878
expect(auth.auth.api.forgetPassword).not.toHaveBeenCalled()

apps/sim/app/api/auth/forget-password/route.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ const forgetPasswordSchema = z.object({
1414
.email('Please provide a valid email address'),
1515
redirectTo: z
1616
.string()
17-
.url('Redirect URL must be a valid URL')
18-
.refine((url) => isSameOrigin(url), {
19-
message: 'Redirect URL must be same-origin',
20-
})
2117
.optional()
2218
.or(z.literal(''))
23-
.transform((val) => (val === '' ? undefined : val)),
19+
.transform((val) => (val === '' || val === undefined ? undefined : val))
20+
.refine(
21+
(val) => val === undefined || (z.string().url().safeParse(val).success && isSameOrigin(val)),
22+
{
23+
message: 'Redirect URL must be a valid same-origin URL',
24+
}
25+
),
2426
})
2527

2628
export async function POST(request: NextRequest) {

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/**
22
* Environment utility functions for consistent environment detection across the application
33
*/
4-
5-
import { createLogger } from '@/lib/logs/console/logger'
64
import { env, getEnv, isTruthy } from './env'
75

8-
const logger = createLogger('FeatureFlags')
9-
106
/**
117
* Is the application running in production mode
128
*/
@@ -46,16 +42,22 @@ export const isEmailVerificationEnabled = isTruthy(env.EMAIL_VERIFICATION_ENABLE
4642
export const isAuthDisabled = isTruthy(env.DISABLE_AUTH) && !isHosted
4743

4844
if (isTruthy(env.DISABLE_AUTH)) {
49-
if (isHosted) {
50-
logger.error(
51-
'DISABLE_AUTH is set but ignored on hosted environment. Authentication remains enabled for security.'
52-
)
53-
} else {
54-
logger.warn(
55-
'DISABLE_AUTH is enabled. Authentication is bypassed and all requests use an anonymous session. ' +
56-
'Only use this in trusted private networks.'
57-
)
58-
}
45+
import('@/lib/logs/console/logger')
46+
.then(({ createLogger }) => {
47+
const logger = createLogger('FeatureFlags')
48+
if (isHosted) {
49+
logger.error(
50+
'DISABLE_AUTH is set but ignored on hosted environment. Authentication remains enabled for security.'
51+
)
52+
} else {
53+
logger.warn(
54+
'DISABLE_AUTH is enabled. Authentication is bypassed and all requests use an anonymous session. Only use this in trusted private networks.'
55+
)
56+
}
57+
})
58+
.catch(() => {
59+
// Fallback during config compilation when logger is unavailable
60+
})
5961
}
6062

6163
/**

0 commit comments

Comments
 (0)