diff --git a/backend/src/auth/router.py b/backend/src/auth/router.py index 457607fa..3a553fec 100644 --- a/backend/src/auth/router.py +++ b/backend/src/auth/router.py @@ -38,7 +38,9 @@ @router.post("/signup") -def sign_up(data: SignUpData, session=Depends(get_session)): +def sign_up( + data: SignUpData, response: Response, session=Depends(get_session) +) -> Token: existing_user = session.scalars( select(User).where(User.email == data.email) ).first() @@ -52,8 +54,9 @@ def sign_up(data: SignUpData, session=Depends(get_session)): ) session.add(new_user) session.commit() + session.refresh(new_user) - return + return create_token(new_user, response) @router.post("/login") diff --git a/backend/src/events/process.py b/backend/src/events/process.py index 227b4743..4962d426 100644 --- a/backend/src/events/process.py +++ b/backend/src/events/process.py @@ -41,8 +41,7 @@ def add_event_to_db(event: EventLLM) -> bool: eventORM = session.scalars( select(Event).where( Event.title == event.title, - Event.description == Event.description, - Event.duplicate == event.duplicate, + Event.description == event.description, Event.is_singapore == event.is_singapore, Event.original_article_id == event.original_article_id, ) diff --git a/frontend/app/(unauthenticated)/register/page.tsx b/frontend/app/(unauthenticated)/register/page.tsx index 4b026381..f596061f 100644 --- a/frontend/app/(unauthenticated)/register/page.tsx +++ b/frontend/app/(unauthenticated)/register/page.tsx @@ -16,6 +16,7 @@ import { Alert, AlertDescription } from "@/components/ui/alert"; import { Box } from "@/components/ui/box"; import { Button } from "@/components/ui/button"; import { Form } from "@/components/ui/form"; +import { useUserStore } from "@/store/user/user-store-provider"; const registerFormSchema = z.object({ email: z.string().email("Invalid email address"), @@ -31,6 +32,7 @@ type RegisterForm = z.infer; function RegisterPage() { const router = useRouter(); + const setLoggedIn = useUserStore((state) => state.setLoggedIn); const [isError, setIsError] = useState(false); const form = useForm({ resolver: zodResolver(registerFormSchema), @@ -47,6 +49,7 @@ function RegisterPage() { setIsError(true); } else { setIsError(false); + setLoggedIn(response.data.user); router.push("/login"); } }; diff --git a/frontend/client/types.gen.ts b/frontend/client/types.gen.ts index 32ef05b3..040e3131 100644 --- a/frontend/client/types.gen.ts +++ b/frontend/client/types.gen.ts @@ -166,7 +166,7 @@ export type SignUpAuthSignupPostData = { body: SignUpData; }; -export type SignUpAuthSignupPostResponse = (unknown); +export type SignUpAuthSignupPostResponse = (Token); export type SignUpAuthSignupPostError = (HTTPValidationError);