Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions apps/studio/components/interfaces/SignIn/SignUpForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { parseAsString, useQueryStates } from 'nuqs'
import { useRef, useState } from 'react'
import { toast } from 'sonner'
import * as yup from 'yup'
import { useRouter } from 'next/router'

import { useSignUpMutation } from 'data/misc/signup-mutation'
import { BASE_PATH } from 'lib/constants'
import { passwordSchema } from 'lib/schemas'
import { buildPathWithParams } from 'lib/gotrue'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
Expand All @@ -28,6 +30,7 @@ const SignUpForm = () => {
const [isSubmitted, setIsSubmitted] = useState(false)
const [passwordHidden, setPasswordHidden] = useState(true)
const [captchaToken, setCaptchaToken] = useState<string | null>(null)
const router = useRouter()

const [searchParams] = useQueryStates({
auth_id: parseAsString.withDefault(''),
Expand Down Expand Up @@ -59,9 +62,19 @@ const SignUpForm = () => {
? location.origin
: process.env.NEXT_PUBLIC_SITE_URL
}${BASE_PATH}`
const redirectTo = isInsideOAuthFlow
? `${redirectUrlBase}/authorize?auth_id=${searchParams.auth_id}${searchParams.token && `&token=${searchParams.token}`}`
: `${redirectUrlBase}/sign-in`

let redirectTo: string

if (isInsideOAuthFlow) {
redirectTo = `${redirectUrlBase}/authorize?auth_id=${searchParams.auth_id}${searchParams.token && `&token=${searchParams.token}`}`
} else {
// Use getRedirectToPath to handle redirect_to parameter and other query params
const { returnTo } = router.query
const basePath = returnTo || '/sign-in'
const fullPath = buildPathWithParams(basePath as string)
const fullRedirectUrl = `${redirectUrlBase}${fullPath}`
redirectTo = fullRedirectUrl
}

signup({
email,
Expand Down
Loading