Skip to content

Commit

Permalink
fix: discard email-verification notification. Users now can be prompt…
Browse files Browse the repository at this point in the history
… to repo page after register
  • Loading branch information
James-Leste committed Dec 7, 2024
1 parent a9efb8a commit 774ed7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions app/authentication/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,21 @@ export async function emailSignup(formData: FormData) {

// type-casting here for convenience
// in practice, you should validate your inputs
const data = {
const credentials = {
email: formData.get('email') as string,
password: formData.get('password') as string,
}

const { error } = await supabase.auth.signUp(data)
const { data, error } = await supabase.auth.signUp(credentials)

if (error) {
return { success: false, message: error.message }
return { success: false, message: error.message, data: null }
}

return {
success: true,
message: 'Please check your email to confirm your signup.',
message: 'User has successfully signed up.',
data: data,
}
}

Expand Down
17 changes: 10 additions & 7 deletions app/authentication/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { emailSignup } from '../actions'
import { Button } from '@/components/ui/button'
import { useRouter } from 'next/navigation'
import { toast } from 'sonner'
import { User } from '@supabase/supabase-js'

export default function RegisterPage() {
const [email, setEmail] = useState('')
Expand All @@ -18,21 +19,23 @@ export default function RegisterPage() {
}
async function handleSignup(event: FormData) {
const response = await emailSignup(event)
console.log(response)
const email = event.get('email') as string
const emailDomain = email.split('@')[1]

if (response.success) {
console.log(response.data)
// const email = event.get('email') as string
// const emailDomain = email.split('@')[1]

if (response.success && response.data) {
const user: User | null = response.data.user
toast(response.message, {
action: {
label: 'GO',
onClick: () =>
window.open(`https://${emailDomain}`, '_blank'),
label: 'Personal Page',
onClick: () => router.push(`/user/${user?.id}`),
},
})
} else {
toast.error(response.message)
}
console.log(`${location.origin}/user/${123}`)
}
return (
<div className='h-screen grid grid-cols-2 gap-3 items-center justify-center bg-customeBG1 p-4 '>
Expand Down

0 comments on commit 774ed7b

Please sign in to comment.