fix(auth): secure white-label invite and reset links (#1680)

This commit is contained in:
Mattsson
2026-08-18 23:17:26 +02:00
committed by GitHub
parent 3ec76d39db
commit dfa7097f3a
9 changed files with 362 additions and 9 deletions
@@ -0,0 +1,17 @@
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
const SOURCE = readFileSync(
fileURLToPath(new URL('../login-client.tsx', import.meta.url)),
'utf8',
)
describe('password reset redirect wiring', () => {
it('routes the browser origin through the trusted app-origin resolver', () => {
expect(SOURCE).toContain('buildPasswordResetRedirectTo(window.location.origin)')
expect(SOURCE).not.toContain(
'`${window.location.origin}/auth/callback?next=/reset-password`',
)
})
})
+2 -1
View File
@@ -32,6 +32,7 @@ import {
consumeInviteCookie,
INVITE_PROBLEM_MESSAGE_KEYS,
} from '@/lib/auth/consume-invite-cookie'
import { buildPasswordResetRedirectTo } from '@/lib/domains/trusted-app-origin'
import { AuthFormError } from '@/components/auth/AuthFormError'
import { GoogleAuthButton } from '@/components/auth/GoogleAuthButton'
import { isGoogleAuthEnabled } from '@/lib/auth/google-oauth'
@@ -326,7 +327,7 @@ export function LoginClient({ initialMethod }: { initialMethod: LoginMethod | nu
try {
const { error } = await supabase.auth.resetPasswordForEmail(emailValue, {
redirectTo: `${window.location.origin}/auth/callback?next=/reset-password`,
redirectTo: buildPasswordResetRedirectTo(window.location.origin),
})
if (error) {