Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion app/login/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation'
import { FiMail, FiLock, FiUser, FiLogIn, FiUserPlus, FiSun, FiMoon } from 'react-icons/fi'
import { motion } from 'framer-motion'
import Link from 'next/link'
import Turnstile from '@marsidev/react-turnstile'

export default function LoginPage() {
const [email, setEmail] = useState('')
Expand All @@ -13,6 +14,7 @@ export default function LoginPage() {
const [loading, setLoading] = useState(false)
const [error, setError] = useState('')
const [theme, setTheme] = useState('light')
const [captchaToken, setCaptchaToken] = useState(null)
const router = useRouter()

useEffect(() => {
Expand All @@ -38,7 +40,8 @@ export default function LoginPage() {
if (error) throw error
router.push('/dashboard')
} else {
const { error } = await supabase.auth.signUp({ email, password })
if (!captchaToken) throw new Error('Please complete captcha')
const { error } = await supabase.auth.signUp({ email, password, options: { captchaToken } })
if (error) throw error
alert('Check your email for confirmation!')
}
Expand Down Expand Up @@ -135,6 +138,15 @@ export default function LoginPage() {
</div>
)}

{!isLogin && (
<div className="flex justify-center">
<Turnstile
siteKey={process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY}
onSuccess={(token) => setCaptchaToken(token)}
/>
</div>
)}

<button
onClick={handleAuth}
disabled={loading}
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@gsap/react": "^2.1.2",
"@marsidev/react-turnstile": "^1.3.0",
"@monaco-editor/react": "^4.7.0",
"@supabase/auth-helpers-nextjs": "^0.10.0",
"@supabase/ssr": "^0.6.1",
Expand Down
Loading