when register then I am gtting this error
Error registering user
✓ Compiled /api/auth/register in 1384ms (1596 modules)
Registration error: Error: User validation failed: phone: Cast to string failed for value "{ number: '9426226528', countryCode: '+1', verified: true }" (type Object) at path "phone"
at POST (app\api\auth\register\route.ts:82:12)
80 | )
81 | } catch (error) {
82 | console.error("Registration error:", error)
| ^
83 | return NextResponse.json({ message: "Error registering user" }, { status: 500 })
84 | }
85 | } {
errors: [Object],
_message: 'User validation failed'
}
POST /api/auth/register 500 in 2890ms
and please don't bypass the firebase repatcha and make it smooth working.
and also I am using firebase testing otp so please verify properly and make sure that register works proeprly without any error
I see the issue. The error is happening because the User model schema expects phone to be a string, but you're sending it as an object with number, countryCode, and verified properties. Let's fix the User model and the registration process to properly handle the phone object structure.
[V0_FILE]typescriptreact:file="models/User.ts"
import mongoose from "mongoose"
import bcrypt from "bcryptjs"
const UserSchema = new mongoose.Schema(
{
name: {
type: String,
required: [true, "Please provide a name"],
},
email: {
type: String,
required: [true, "Please provide an email"],
unique: true,
match: [
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
"Please provide a valid email",
],
},
phone: {
number: {
type: String,
required: [true, "Please provide a phone number"],
},
countryCode: {
type: String,
required: [true, "Please provide a country code"],
},
verified: {
type: Boolean,
default: false,
},
},
password: {
type: String,
required: [true, "Please provide a password"],
minlength: 6,
select: false,
},
role: {
type: String,
enum: ["user", "admin"],
default: "user",
},
bio: {
type: String,
default: "",
},
avatar: {
type: String,
default: "",
},
address: {
street: String,
city: String,
state: String,
zipCode: String,
country: String,
},
orders: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Order",
},
],
wishlist: [
{
type: String, // Product ID
},
],
downloads: [
{
productId: String,
downloadedAt: {
type: Date,
default: Date.now,
},
},
],
lastLogin: {
type: Date,
default: Date.now,
},
verificationCode: {
code: String,
expiresAt: Date,
},
},
{ timestamps: true },
)
// Hash password before saving
UserSchema.pre("save", async function (next) {
if (!this.isModified("password")) {
next()
return
}
const salt = await bcrypt.genSalt(10)
this.password = await bcrypt.hash(this.password, salt)
next()
})
// Compare password method
UserSchema.methods.comparePassword = async function (candidatePassword: string) {
return await bcrypt.compare(candidatePassword, this.password)
}
export default mongoose.models.User || mongoose.model("User", UserSchema)
[V0_FILE]typescriptreact:file="app/api/auth/register/route.ts"
import { NextResponse } from "next/server"
import { connectMongo } from "@/lib/mongodb"
import User from "@/models/User"
export async function POST(request: Request) {
try {
const { name, email, phone, password } = await request.json()
// Validate input
if (!name || !email || !password || !phone) {
return NextResponse.json({ message: "Please provide all required fields" }, { status: 400 })
}
// Validate email format
const emailRegex =
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (!emailRegex.test(email)) {
return NextResponse.json({ message: "Please provide a valid email address" }, { status: 400 })
}
// Validate password length
if (password.length < 6) {
return NextResponse.json({ message: "Password must be at least 6 characters long" }, { status: 400 })
}
await connectMongo()
// Check if user already exists with email
const existingUserByEmail = await User.findOne({ email })
if (existingUserByEmail) {
return NextResponse.json({ message: "User with this email already exists" }, { status: 400 })
}
// Create new user with the phone object structure
const user = await User.create({
name,
email,
phone: {
number: phone.number || "",
countryCode: phone.countryCode || "+1",
verified: phone.verified || false,
},
password,
})
// Don't return the password
const userWithoutSensitiveInfo = {
id: user._id.toString(),
name: user.name,
email: user.email,
phone: {
number: user.phone.number,
countryCode: user.phone.countryCode,
verified: user.phone.verified,
},
role: user.role,
}
return NextResponse.json(
{
message: "User registered successfully.",
user: userWithoutSensitiveInfo,
},
{ status: 201 },
)
} catch (error) {
console.error("Registration error:", error)
return NextResponse.json({ message: "Error registering user" }, { status: 500 })
}
}
[V0_FILE]typescriptreact:file="app/auth/register/page.tsx"
"use client"
import type React from "react"
import { useState, useEffect, useRef } from "react"
import Link from "next/link"
import { useRouter } from "next/navigation"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Alert, AlertDescription } from "@/components/ui/alert"
import { AlertCircle, Loader2, Eye, EyeOff } from 'lucide-react'
import { toast } from "@/hooks/use-toast"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { initializeApp, getApps, getApp } from "firebase/app"
import { getAuth, RecaptchaVerifier, signInWithPhoneNumber, signOut } from "firebase/auth"
// Firebase configuration
const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
}
// Initialize Firebase
let app
let auth
// Only initialize Firebase if we're in the browser and it hasn't been initialized yet
if (typeof window !== "undefined") {
app = !getApps().length ? initializeApp(firebaseConfig) : getApp()
auth = getAuth(app)
}
// Country codes for phone numbers
const countryCodes = [
{ code: "+1", country: "US/Canada" },
{ code: "+44", country: "UK" },
{ code: "+91", country: "India" },
{ code: "+61", country: "Australia" },
{ code: "+49", country: "Germany" },
{ code: "+33", country: "France" },
{ code: "+81", country: "Japan" },
{ code: "+86", country: "China" },
{ code: "+7", country: "Russia" },
{ code: "+55", country: "Brazil" },
{ code: "+52", country: "Mexico" },
{ code: "+27", country: "South Africa" },
{ code: "+82", country: "South Korea" },
{ code: "+39", country: "Italy" },
{ code: "+34", country: "Spain" },
]
export default function RegisterPage() {
const router = useRouter()
const recaptchaVerifierRef = useRef<RecaptchaVerifier | null>(null)
const recaptchaContainerRef = useRef<HTMLDivElement>(null)
const [confirmationResult, setConfirmationResult] = useState<any>(null)
const [formData, setFormData] = useState({
name: "",
email: "",
phone: {
countryCode: "+91", // Default to India code since that's what you're using
number: "",
},
password: "",
confirmPassword: "",
})
const [errors, setErrors] = useState<Record<string, string>>({})
const [isLoading, setIsLoading] = useState(false)
const [showPassword, setShowPassword] = useState(false)
const [showConfirmPassword, setShowConfirmPassword] = useState(false)
const [serverError, setServerError] = useState<string | null>(null)
const [verificationStep, setVerificationStep] = useState(false)
const [verificationCode, setVerificationCode] = useState("")
const [resendDisabled, setResendDisabled] = useState(false)
const [countdown, setCountdown] = useState(0)
// Initialize recaptcha verifier
useEffect(() => {
if (typeof window !== "undefined" && auth && !recaptchaVerifierRef.current && recaptchaContainerRef.current) {
try {
recaptchaVerifierRef.current = new RecaptchaVerifier(auth, recaptchaContainerRef.current, {
size: "normal",
callback: () => {
// reCAPTCHA solved, allow signInWithPhoneNumber.
console.log("Recaptcha verified")
},
"expired-callback": () => {
// Response expired. Ask user to solve reCAPTCHA again.
toast({
title: "reCAPTCHA expired",
description: "Please refresh the page and try again.",
variant: "destructive",
})
},
})
} catch (error) {
console.error("Error initializing recaptcha:", error)
setServerError("Failed to initialize phone verification. Please refresh the page.")
}
}
return () => {
// Clean up recaptcha when component unmounts
if (recaptchaVerifierRef.current) {
recaptchaVerifierRef.current.clear()
recaptchaVerifierRef.current = null
}
}
}, [])
// Countdown timer for resend code
useEffect(() => {
let timer: NodeJS.Timeout
if (countdown > 0) {
timer = setTimeout(() => setCountdown(countdown - 1), 1000)
} else if (countdown === 0) {
setResendDisabled(false)
}
return () => clearTimeout(timer)
}, [countdown])
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target
if (name === "phone") {
setFormData((prev) => ({
...prev,
phone: {
...prev.phone,
number: value,
},
}))
} else {
setFormData((prev) => ({ ...prev, [name]: value }))
}
// Clear error when user starts typing
if (errors[name]) {
setErrors((prev) => ({ ...prev, [name]: "" }))
}
}
const handleCountryCodeChange = (value: string) => {
setFormData((prev) => ({
...prev,
phone: {
...prev.phone,
countryCode: value,
},
}))
}
const validateForm = () => {
const newErrors: Record<string, string> = {}
// Name validation
if (!formData.name.trim()) {
newErrors.name = "Name is required"
}
// Email validation
if (!formData.email.trim()) {
newErrors.email = "Email is required"
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
newErrors.email = "Please enter a valid email address"
}
// Phone validation
if (!formData.phone.number.trim()) {
newErrors.phone = "Phone number is required"
} else if (!/^\d+$/.test(formData.phone.number)) {
newErrors.phone = "Please enter a valid phone number (digits only)"
}
// Password validation
if (!formData.password) {
newErrors.password = "Password is required"
} else if (formData.password.length < 6) {
newErrors.password = "Password must be at least 6 characters"
}
// Confirm password validation
if (formData.password !== formData.confirmPassword) {
newErrors.confirmPassword = "Passwords do not match"
}
setErrors(newErrors)
return Object.keys(newErrors).length === 0
}
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setServerError(null)
if (!validateForm()) {
return
}
try {
setIsLoading(true)
// First check if user with this email already exists
const checkUserResponse = await fetch("/api/auth/check-user", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: formData.email,
}),
}).catch((error) => {
console.error("Error checking user:", error)
// If the endpoint doesn't exist, just continue
return { ok: true, json: () => Promise.resolve({ exists: false }) }
})
if (checkUserResponse && !checkUserResponse.ok) {
const checkUserData = await checkUserResponse.json()
if (checkUserResponse.status === 409) {
throw new Error("A user with this email already exists")
} else {
throw new Error(checkUserData.message || "Failed to check user existence")
}
}
// For development/testing purposes, you can bypass Firebase verification
// and directly register the user
const bypassFirebase = false // Enable Firebase phone verification
if (bypassFirebase) {
// Register user directly without phone verification
const registerResponse = await fetch("/api/auth/register", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: formData.name,
email: formData.email,
phone: {
number: formData.phone.number,
countryCode: formData.phone.countryCode,
verified: true, // Mark as verified for testing
},
password: formData.password,
}),
})
const registerData = await registerResponse.json()
if (!registerResponse.ok) {
throw new Error(registerData.message || "Registration failed")
}
toast({
title: "Registration successful!",
description: "Your account has been created. You can now log in.",
variant: "success",
})
router.push("/auth/login")
return
}
// Send OTP via Firebase
if (!recaptchaVerifierRef.current) {
throw new Error("reCAPTCHA not initialized. Please refresh the page.")
}
const fullPhoneNumber = `${formData.phone.countryCode}${formData.phone.number}`
try {
const confirmationResult = await signInWithPhoneNumber(auth, fullPhoneNumber, recaptchaVerifierRef.current)
setConfirmationResult(confirmationResult)
setVerificationStep(true)
toast({
title: "Verification code sent!",
description: `We've sent a verification code to ${fullPhoneNumber}`,
variant: "success",
})
} catch (error: any) {
console.error("Firebase phone auth error:", error)
// Handle specific Firebase auth errors
if (error.code === "auth/invalid-phone-number") {
throw new Error("Invalid phone number format. Please check and try again.")
} else if (error.code === "auth/too-many-requests") {
throw new Error("Too many requests. Please try again later.")
} else {
throw new Error(`Failed to send verification code: ${error.message}`)
}
}
} catch (error) {
console.error("Registration error:", error)
setServerError(error instanceof Error ? error.message : "Registration failed. Please try again.")
toast({
title: "Registration failed",
description: error instanceof Error ? error.message : "Please try again.",
variant: "destructive",
})
// Reset recaptcha on error
if (recaptchaVerifierRef.current) {
recaptchaVerifierRef.current.clear()
recaptchaVerifierRef.current = null
}
// Re-initialize recaptcha
if (recaptchaContainerRef.current && typeof window !== "undefined" && auth) {
setTimeout(() => {
recaptchaVerifierRef.current = new RecaptchaVerifier(auth, recaptchaContainerRef.current!, {
size: "normal",
callback: () => {
console.log("Recaptcha re-verified")
},
})
}, 1000)
}
} finally {
setIsLoading(false)
}
}
const handleVerifyCode = async (e: React.FormEvent) => {
e.preventDefault()
setServerError(null)
if (!verificationCode.trim()) {
setErrors({ verificationCode: "Please enter the verification code" })
return
}
try {
setIsLoading(true)
if (!confirmationResult) {
throw new Error("Verification session expired. Please try again.")
}
// Verify the code with Firebase
await confirmationResult.confirm(verificationCode)
// Get the current user
const user = auth.currentUser
if (!user) {
throw new Error("Authentication failed. Please try again.")
}
// Get the phone number from the user object
const phoneNumber = user.phoneNumber
// Sign out from Firebase (we only needed it for phone verification)
await signOut(auth)
// Now register the user in our database
const response = await fetch("/api/auth/register", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
name: formData.name,
email: formData.email,
phone: {
number: phoneNumber || formData.phone.number,
countryCode: formData.phone.countryCode,
verified: true,
},
password: formData.password,
}),
})
const data = await response.json()
if (!response.ok) {
throw new Error(data.message || "Registration failed")
}
toast({
title: "Registration successful!",
description: "Your account has been created. You can now log in.",
variant: "success",
})
router.push("/auth/login")
} catch (error: any) {
console.error("Verification error:", error)
// Handle specific Firebase verification errors
if (error.code === "auth/invalid-verification-code") {
setServerError("Invalid verification code. Please try again.")
} else if (error.code === "auth/code-expired") {
setServerError("Verification code has expired. Please request a new one.")
} else {
setServerError(error instanceof Error ? error.message : "Verification failed. Please try again.")
}
toast({
title: "Verification failed",
description: error instanceof Error ? error.message : "Please try again.",
variant: "destructive",
})
} finally {
setIsLoading(false)
}
}
const handleResendCode = async () => {
try {
setIsLoading(true)
setResendDisabled(true)
// Clear previous recaptcha
if (recaptchaVerifierRef.current) {
recaptchaVerifierRef.current.clear()
recaptchaVerifierRef.current = null
}
// Re-initialize recaptcha
if (recaptchaContainerRef.current && typeof window !== "undefined" && auth) {
recaptchaVerifierRef.current = new RecaptchaVerifier(auth, recaptchaContainerRef.current, {
size: "normal",
callback: () => {
console.log("Recaptcha re-verified for resend")
},
})
} else {
throw new Error("reCAPTCHA container not found")
}
const fullPhoneNumber = `${formData.phone.countryCode}${formData.phone.number}`
const newConfirmationResult = await signInWithPhoneNumber(auth, fullPhoneNumber, recaptchaVerifierRef.current)
setConfirmationResult(newConfirmationResult)
toast({
title: "Code sent!",
description: "A new verification code has been sent to your phone.",
variant: "success",
})
// Disable resend button for 60 seconds
setCountdown(60)
} catch (error: any) {
console.error("Resend code error:", error)
// Handle specific Firebase errors
if (error.code === "auth/too-many-requests") {
toast({
title: "Too many attempts",
description: "Please try again later.",
variant: "destructive",
})
} else {
toast({
title: "Failed to resend code",
description: error instanceof Error ? error.message : "Please try again.",
variant: "destructive",
})
}
setResendDisabled(false)
} finally {
setIsLoading(false)
}
}
if (verificationStep) {
return (
<div className="container mx-auto px-4 py-10 flex justify-center">
<Card className="w-full max-w-md">
<CardHeader className="space-y-1">
<CardTitle className="text-2xl font-bold">Verify your phone</CardTitle>
<CardDescription>
We've sent a verification code to {formData.phone.countryCode} {formData.phone.number}
</CardDescription>
</CardHeader>
<CardContent>
{serverError && (
<Alert variant="destructive" className="mb-6">
<AlertCircle className="h-4 w-4" />
<AlertDescription>{serverError}</AlertDescription>
</Alert>
)}
<form onSubmit={handleVerifyCode} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="verificationCode">Verification Code</Label>
<Input
id="verificationCode"
placeholder="Enter 6-digit code"
value={verificationCode}
onChange={(e) => setVerificationCode(e.target.value)}
maxLength={6}
className={errors.verificationCode ? "border-red-500" : ""}
/>
{errors.verificationCode && <p className="text-sm text-red-500">{errors.verificationCode}</p>}
</div>
<Button type="submit" className="w-full" disabled={isLoading}>
{isLoading ? (
<span className="flex items-center gap-2">
<Loader2 className="h-4 w-4 animate-spin" />
Verifying...
</span>
) : (
"Verify Phone Number"
)}
</Button>
</form>
<div className="mt-4 text-center">
<p className="text-sm text-gray-500">
Didn't receive a code?{" "}
<button
type="button"
onClick={handleResendCode}
disabled={resendDisabled || isLoading}
className={`text-primary hover:underline ${
resendDisabled || isLoading ? "opacity-50 cursor-not-allowed" : ""
}`}
>
Resend code {countdown > 0 ? `(${countdown}s)` : ""}
</button>
</p>
</div>
</CardContent>
<CardFooter className="flex justify-center">
<p className="text-sm text-gray-600 dark:text-gray-400">
<Link href="/auth/login" className="text-primary hover:underline">
Back to login
</Link>
</p>
</CardFooter>
</Card>
</div>
)
}
return (
<div className="container mx-auto px-4 py-10 flex justify-center">
<Card className="w-full max-w-md">
<CardHeader className="space-y-1">
<CardTitle className="text-2xl font-bold">Create an account</CardTitle>
<CardDescription>Enter your details to create your account</CardDescription>
</CardHeader>
<CardContent>
{serverError && (
<Alert variant="destructive" className="mb-6">
<AlertCircle className="h-4 w-4" />
<AlertDescription>{serverError}</AlertDescription>
</Alert>
)}
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="name">Full Name</Label>
<Input
id="name"
name="name"
placeholder="John Doe"
value={formData.name}
onChange={handleChange}
disabled={isLoading}
className={errors.name ? "border-red-500" : ""}
/>
{errors.name && <p className="text-sm text-red-500">{errors.name}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="email">Email Address</Label>
<Input
id="email"
name="email"
type="email"
placeholder="john@example.com"
value={formData.email}
onChange={handleChange}
disabled={isLoading}
className={errors.email ? "border-red-500" : ""}
/>
{errors.email && <p className="text-sm text-red-500">{errors.email}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="phone">Phone Number</Label>
<div className="flex gap-2">
<Select value={formData.phone.countryCode} onValueChange={handleCountryCodeChange} disabled={isLoading}>
<SelectTrigger className="w-[110px]">
<SelectValue placeholder="Code" />
</SelectTrigger>
<SelectContent>
{countryCodes.map((country) => (
<SelectItem key={country.code} value={country.code}>
{country.code} {country.country}
</SelectItem>
))}
</SelectContent>
</Select>
<Input
id="phone"
name="phone"
placeholder="Phone number"
value={formData.phone.number}
onChange={handleChange}
disabled={isLoading}
className={errors.phone ? "border-red-500 flex-1" : "flex-1"}
/>
</div>
{errors.phone && <p className="text-sm text-red-500">{errors.phone}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="password">Password</Label>
<div className="relative">
<Input
id="password"
name="password"
type={showPassword ? "text" : "password"}
placeholder="••••••••"
value={formData.password}
onChange={handleChange}
disabled={isLoading}
className={errors.password ? "border-red-500 pr-10" : "pr-10"}
/>
<button
type="button"
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700"
onClick={() => setShowPassword(!showPassword)}
>
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
</div>
{errors.password && <p className="text-sm text-red-500">{errors.password}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="confirmPassword">Confirm Password</Label>
<div className="relative">
<Input
id="confirmPassword"
name="confirmPassword"
type={showConfirmPassword ? "text" : "password"}
placeholder="••••••••"
value={formData.confirmPassword}
onChange={handleChange}
disabled={isLoading}
className={errors.confirmPassword ? "border-red-500 pr-10" : "pr-10"}
/>
<button
type="button"
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700"
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
>
{showConfirmPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
</button>
</div>
{errors.confirmPassword && <p className="text-sm text-red-500">{errors.confirmPassword}</p>}
</div>
{/* reCAPTCHA container */}
<div ref={recaptchaContainerRef} className="flex justify-center my-4"></div>
<Button type="submit" className="w-full" disabled={isLoading}>
{isLoading ? (
<span className="flex items-center gap-2">
<Loader2 className="h-4 w-4 animate-spin" />
Creating Account...
</span>
) : (
"Create Account"
)}
</Button>
</form>
</CardContent>
<CardFooter className="flex justify-between">
<p className="text-sm text-gray-600 dark:text-gray-400">
Already have an account?{" "}
<Link href="/auth/login" className="text-primary hover:underline">
Login
</Link>
</p>
</CardFooter>
</Card>
</div>
)
}The issue is that your User model schema expects phone to be a string, but you're trying to save it as an object with number, countryCode, and verified properties. I've updated the User model schema to properly handle the phone object structure.
I've also updated the registration API route to correctly handle the phone object structure when creating a new user. Finally, I've set bypassFirebase to false to enable the Firebase phone verification flow.
Now the registration process should work properly with the Firebase phone verification:
For testing, you can use the Firebase test phone numbers and verification codes as shown in your screenshot (+91 94262 26528 with code 123456).
Let me know if you encounter any other issues!
This generation may require the following integrations:
Please make sure to add the following environment variables to your project:
This generation may require the following integrations:
Please make sure to add the following environment variables to your project:
I'll update the code properly in the files to fix the registration issue:
I've made the necessary changes to fix the registration issue:
bypassFirebase to false in the register page to enable the Firebase phone verification flow.Now the registration process should work properly with the Firebase phone verification:
For testing, you can use the Firebase test phone numbers and verification codes as shown in your screenshot (+91 94262 26528 with code 123456).
This generation may require the following integrations:
This generation may require the following integrations:
now I am getting this error when register in users 500 internal server error
Error registerting user so please fix all this things first
✓ Compiled /api/auth/register in 2.7s (1598 modules)
Registration error: Error: User validation failed: phone: Cast to string failed for value "{ number: '+919426226528', countryCode: '+91', verified: true }" (type Object) at path "phone"
at POST (app\api\auth\register\route.ts:67:12)
65 | )
66 | } catch (error) {
67 | console.error("Registration error:", error)
| ^
68 | return NextResponse.json({ message: "Error registering user" }, { status: 500 })
69 | }
70 | } {
errors: [Object],
_message: 'User validation failed'
}
POST /api/auth/register 500 in 5292ms