Skip to content

Commit

Permalink
🔒 Use sanitizeUrl on redirectPath auth param (#1389)
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno authored Mar 25, 2024
1 parent 2bd1cb7 commit d0be29e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"format:check": "prettier --check ./src"
},
"dependencies": {
"@braintree/sanitize-url": "7.0.1",
"@chakra-ui/anatomy": "2.1.1",
"@chakra-ui/react": "2.7.1",
"@chakra-ui/theme-tools": "2.0.18",
Expand Down
5 changes: 4 additions & 1 deletion apps/builder/src/features/auth/components/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import { useToast } from '@/hooks/useToast'
import { TextLink } from '@/components/TextLink'
import { SignInError } from './SignInError'
import { useTranslate } from '@tolgee/react'
import { sanitizeUrl } from '@braintree/sanitize-url'

type Props = {
defaultEmail?: string
}

export const SignInForm = ({
defaultEmail,
}: Props & HTMLChakraProps<'form'>) => {
Expand All @@ -55,7 +57,8 @@ export const SignInForm = ({

useEffect(() => {
if (status === 'authenticated') {
router.replace(router.query.redirectPath?.toString() ?? '/typebots')
const redirectPath = router.query.redirectPath?.toString()
router.replace(redirectPath ? sanitizeUrl(redirectPath) : '/typebots')
return
}
;(async () => {
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0be29e

Please sign in to comment.