Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/web/app/auth/login/auth-page-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { Content, Header } = Layout;
const { Title, Text } = Typography;

export default function AuthPageContent() {
const { status } = useSession();
const { status, update: updateSession } = useSession();
const router = useRouter();
const searchParams = useSearchParams();
const callbackUrl = searchParams.get('callbackUrl') || '/';
Expand Down Expand Up @@ -56,6 +56,8 @@ export default function AuthPageContent() {
if (result?.error) {
message.error('Invalid email or password');
} else if (result?.ok) {
// Force session refresh so all components get the updated auth state
await updateSession();
message.success('Logged in successfully');
router.push(callbackUrl);
}
Expand Down Expand Up @@ -101,6 +103,8 @@ export default function AuthPageContent() {
});

if (loginResult?.ok) {
// Force session refresh so all components get the updated auth state
await updateSession();
router.push(callbackUrl);
} else {
// If auto-login fails, switch to login tab
Expand Down
7 changes: 6 additions & 1 deletion packages/web/app/components/auth/auth-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState } from 'react';
import { Modal, Form, Input, Button, Tabs, Typography, Divider, message, Space } from 'antd';
import { UserOutlined, LockOutlined, MailOutlined, HeartFilled } from '@ant-design/icons';
import { signIn } from 'next-auth/react';
import { signIn, useSession } from 'next-auth/react';

const { Text } = Typography;

Expand All @@ -22,6 +22,7 @@ export default function AuthModal({
title = "Sign in to continue",
description = "Create an account or sign in to save your favorites and more."
}: AuthModalProps) {
const { update: updateSession } = useSession();
const [loginForm] = Form.useForm();
const [registerForm] = Form.useForm();
const [loginLoading, setLoginLoading] = useState(false);
Expand All @@ -42,6 +43,8 @@ export default function AuthModal({
if (result?.error) {
message.error('Invalid email or password');
} else if (result?.ok) {
// Force session refresh so all components get the updated auth state
await updateSession();
message.success('Logged in successfully');
loginForm.resetFields();
onClose();
Expand Down Expand Up @@ -87,6 +90,8 @@ export default function AuthModal({
});

if (loginResult?.ok) {
// Force session refresh so all components get the updated auth state
await updateSession();
registerForm.resetFields();
onClose();
onSuccess?.();
Expand Down
Loading