Skip to content

Commit

Permalink
Merge branch 'main' into haoyang/integrate-part1
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyangw committed Sep 24, 2024
2 parents 779dde1 + c9e2c57 commit 35d0c75
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
7 changes: 5 additions & 2 deletions backend/src/auth/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down
13 changes: 13 additions & 0 deletions backend/src/events/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ def add_event_to_db(event: EventLLM) -> bool:
categories = get_categories()

with Session(engine) as session:
# Check for duplicates
eventORM = session.scalars(
select(Event).where(
Event.title == event.title,
Event.description == event.description,
Event.is_singapore == event.is_singapore,
Event.original_article_id == event.original_article_id,
)
).first()
if eventORM:
print("duplicate detected:", event)
return False

try:
article = session.get(Article, event.original_article_id)
if not article:
Expand Down
4 changes: 2 additions & 2 deletions backend/src/scripts/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_associations():
# session.delete(original_article)


# test_associations()
test_associations()

def put_sample_events():
"""
Expand Down Expand Up @@ -296,4 +296,4 @@ def put_sample_events():
print(event2)
event_id = event.id

# put_sample_events()
# put_sample_events()
3 changes: 3 additions & 0 deletions frontend/app/(unauthenticated)/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -31,6 +32,7 @@ type RegisterForm = z.infer<typeof registerFormSchema>;

function RegisterPage() {
const router = useRouter();
const setLoggedIn = useUserStore((state) => state.setLoggedIn);
const [isError, setIsError] = useState<boolean>(false);
const form = useForm<RegisterForm>({
resolver: zodResolver(registerFormSchema),
Expand All @@ -47,6 +49,7 @@ function RegisterPage() {
setIsError(true);
} else {
setIsError(false);
setLoggedIn(response.data.user);
router.push("/login");
}
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export type SignUpAuthSignupPostData = {
body: SignUpData;
};

export type SignUpAuthSignupPostResponse = (unknown);
export type SignUpAuthSignupPostResponse = (Token);

export type SignUpAuthSignupPostError = (HTTPValidationError);

Expand Down

0 comments on commit 35d0c75

Please sign in to comment.