Compare commits

..

No commits in common. "ce7bb81e64def42c897681790afde622bfbe66f2" and "ccc1164fa8b7689b7e528c2d1bab38755cbc8ef8" have entirely different histories.

3 changed files with 28 additions and 39 deletions

View file

@ -110,10 +110,8 @@ def create_rating(
session.refresh(existing_rating)
return existing_rating
# Create new rating with user_id injected
rating_data = rating.model_dump()
rating_data["user_id"] = current_user.id
db_rating = Rating.model_validate(rating_data)
db_rating = Rating.model_validate(rating)
db_rating.user_id = current_user.id
session.add(db_rating)
# Award XP for new rating

View file

@ -156,10 +156,9 @@
### Immediate (Testing)
1. [x] Register test account to trigger verification email
2. [x] Registration UX shows "Check Your Email" message
3. [ ] Test password reset flow
4. [ ] Monitor email deliverability in Postal dashboard
1. [ ] Register test account to trigger verification email
2. [ ] Test password reset flow
3. [ ] Monitor email deliverability in Postal dashboard
### This Week

View file

@ -1,20 +1,23 @@
"use client"
import { useState } from "react"
import { useRouter } from "next/navigation"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { getApiUrl } from "@/lib/api-config"
import Link from "next/link"
import { useAuth } from "@/contexts/auth-context"
export default function RegisterPage() {
const [email, setEmail] = useState("")
const [username, setUsername] = useState("")
const [password, setPassword] = useState("")
const [error, setError] = useState("")
const router = useRouter()
const { login } = useAuth()
const [loading, setLoading] = useState(false)
const [success, setSuccess] = useState(false)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
@ -22,7 +25,7 @@ export default function RegisterPage() {
setError("")
try {
// Register
// 1. Register
const res = await fetch(`${getApiUrl()}/auth/register`, {
method: "POST",
headers: {
@ -36,8 +39,24 @@ export default function RegisterPage() {
throw new Error(data.detail || "Registration failed")
}
// Show success message instead of auto-login
setSuccess(true)
// 2. Login automatically
const formData = new URLSearchParams()
formData.append('username', email)
formData.append('password', password)
const loginRes = await fetch(`${getApiUrl()}/auth/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: formData,
})
if (loginRes.ok) {
const loginData = await loginRes.json()
await login(loginData.access_token)
router.push("/profile")
} else {
router.push("/login")
}
} catch (err: any) {
setError(err.message)
@ -46,33 +65,6 @@ export default function RegisterPage() {
}
}
if (success) {
return (
<div className="flex items-center justify-center min-h-[60vh]">
<Card className="w-full max-w-md text-center">
<CardHeader>
<CardTitle className="text-green-600">Check Your Email</CardTitle>
<CardDescription className="text-base">
We&apos;ve sent a verification link to <strong>{email}</strong>
</CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<p className="text-sm text-muted-foreground">
Click the link in the email to verify your account and complete registration.
</p>
<p className="text-xs text-muted-foreground">
Didn&apos;t receive it? Check your spam folder or{" "}
<Link href="/login" className="text-primary hover:underline">
try logging in
</Link>
{" "}to resend.
</p>
</CardContent>
</Card>
</div>
)
}
return (
<div className="flex items-center justify-center min-h-[60vh]">
<Card className="w-full max-w-md">