diff --git a/.changeset/short-cycles-learn.md b/.changeset/short-cycles-learn.md
new file mode 100644
index 000000000..5771d6688
--- /dev/null
+++ b/.changeset/short-cycles-learn.md
@@ -0,0 +1,7 @@
+---
+"@bigcommerce/catalyst-client": patch
+"@bigcommerce/catalyst-core": patch
+"@bigcommerce/create-catalyst": patch
+---
+
+chore: bump next-auth and use string for user id
diff --git a/apps/core/app/[locale]/(default)/login/_components/change-password-form.tsx b/apps/core/app/[locale]/(default)/login/_components/change-password-form.tsx
index 61977785d..e6bcae97f 100644
--- a/apps/core/app/[locale]/(default)/login/_components/change-password-form.tsx
+++ b/apps/core/app/[locale]/(default)/login/_components/change-password-form.tsx
@@ -21,7 +21,7 @@ import { useRouter } from '~/navigation';
import { submitChangePasswordForm } from '../_actions/submit-change-password-form';
interface Props {
- customerId: number;
+ customerId: string;
customerToken: string;
}
diff --git a/apps/core/app/[locale]/(default)/login/page.tsx b/apps/core/app/[locale]/(default)/login/page.tsx
index 6d260fc70..f7391dc48 100644
--- a/apps/core/app/[locale]/(default)/login/page.tsx
+++ b/apps/core/app/[locale]/(default)/login/page.tsx
@@ -39,7 +39,7 @@ export default async function Login({ params: { locale }, searchParams }: Props)
{t('changePasswordHeading')}
-
+
);
diff --git a/apps/core/auth.ts b/apps/core/auth.ts
index 8a23e5361..8132a572f 100644
--- a/apps/core/auth.ts
+++ b/apps/core/auth.ts
@@ -12,14 +12,6 @@ export const Credentials = z.object({
password: z.string().min(1),
});
-declare module 'next-auth' {
- interface Session {
- user?: {
- id?: number;
- };
- }
-}
-
const config = {
session: {
strategy: 'jwt',
@@ -29,9 +21,9 @@ const config = {
},
callbacks: {
session({ session, token }) {
- session.user ||= {};
-
- session.user.id = token.sub ? parseInt(token.sub, 10) : undefined;
+ if (token.sub) {
+ session.user.id = token.sub;
+ }
return session;
},
@@ -40,7 +32,7 @@ const config = {
async signIn({ user }) {
const cookieCartId = cookies().get('cartId')?.value;
- if (cookieCartId) {
+ if (cookieCartId && user.id) {
try {
await assignCartToCustomer(user.id, cookieCartId);
} catch (error) {
@@ -85,20 +77,16 @@ const config = {
],
} satisfies NextAuthConfig;
-const { handlers, auth, signIn, signOut, update } = NextAuth(config);
+const { handlers, auth, signIn, signOut } = NextAuth(config);
const getSessionCustomerId = async () => {
try {
const session = await auth();
- if (!session?.user?.id) {
- return;
- }
-
- return session.user.id;
+ return session?.user?.id;
} catch {
// No empty
}
};
-export { handlers, auth, signIn, signOut, update, getSessionCustomerId };
+export { handlers, auth, signIn, signOut, getSessionCustomerId };
diff --git a/apps/core/client/mutations/apply-checkout-coupon.ts b/apps/core/client/mutations/apply-checkout-coupon.ts
index dfcd96d03..e54cfbab7 100644
--- a/apps/core/client/mutations/apply-checkout-coupon.ts
+++ b/apps/core/client/mutations/apply-checkout-coupon.ts
@@ -28,7 +28,7 @@ export const applyCheckoutCoupon = async (checkoutEntityId: string, couponCode:
},
},
},
- customerId: Number(customerId),
+ customerId,
fetchOptions: { cache: 'no-store' },
});
diff --git a/apps/core/client/mutations/assign-cart-to-customer.ts b/apps/core/client/mutations/assign-cart-to-customer.ts
index 48fd882d3..70f3c4dd8 100644
--- a/apps/core/client/mutations/assign-cart-to-customer.ts
+++ b/apps/core/client/mutations/assign-cart-to-customer.ts
@@ -24,7 +24,7 @@ export const assignCartToCustomer = async (customerId: string, cartEntityId: Car
cartEntityId,
},
},
- customerId: Number(customerId),
+ customerId,
fetchOptions: { cache: 'no-store' },
});
diff --git a/apps/core/client/mutations/unapply-checkout-coupon.ts b/apps/core/client/mutations/unapply-checkout-coupon.ts
index 0f192f561..ba84b143d 100644
--- a/apps/core/client/mutations/unapply-checkout-coupon.ts
+++ b/apps/core/client/mutations/unapply-checkout-coupon.ts
@@ -28,7 +28,7 @@ export const unapplyCheckoutCoupon = async (checkoutEntityId: string, couponCode
},
},
},
- customerId: Number(customerId),
+ customerId,
fetchOptions: { cache: 'no-store' },
});
diff --git a/apps/core/client/mutations/unassign-cart-from-customer.ts b/apps/core/client/mutations/unassign-cart-from-customer.ts
index 15729eba3..34d121478 100644
--- a/apps/core/client/mutations/unassign-cart-from-customer.ts
+++ b/apps/core/client/mutations/unassign-cart-from-customer.ts
@@ -32,7 +32,7 @@ export const unassignCartFromCustomer = async (
cartEntityId,
},
},
- customerId: Number(customerId),
+ customerId,
fetchOptions: { cache: 'no-store' },
});
diff --git a/apps/core/package.json b/apps/core/package.json
index dcd03a257..7d3eb1b4d 100644
--- a/apps/core/package.json
+++ b/apps/core/package.json
@@ -25,7 +25,7 @@
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.365.0",
"next": "^14.1.4",
- "next-auth": "5.0.0-beta.4",
+ "next-auth": "5.0.0-beta.16",
"next-intl": "^3.11.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
diff --git a/packages/client/src/client.ts b/packages/client/src/client.ts
index cd906dfe0..4a868e332 100644
--- a/packages/client/src/client.ts
+++ b/packages/client/src/client.ts
@@ -37,7 +37,7 @@ class Client {
async fetch>(config: {
document: DocumentDecoration;
variables: TVariables;
- customerId?: number;
+ customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise>;
@@ -45,7 +45,7 @@ class Client {
async fetch(config: {
document: DocumentDecoration>;
variables?: undefined;
- customerId?: number;
+ customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise>;
@@ -57,7 +57,7 @@ class Client {
}: {
document: DocumentDecoration;
variables?: TVariables;
- customerId?: number;
+ customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise> {
const { cache, headers = {}, ...rest } = fetchOptions;
@@ -70,7 +70,7 @@ class Client {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.config.customerImpersonationToken}`,
'User-Agent': this.backendUserAgent,
- ...(customerId && { 'X-Bc-Customer-Id': String(customerId) }),
+ ...(customerId && { 'X-Bc-Customer-Id': customerId }),
...headers,
},
body: JSON.stringify({
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c7161c0ce..1f47f6c31 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -66,8 +66,8 @@ importers:
specifier: ^14.1.4
version: 14.1.4(@babel/core@7.24.4)(react-dom@18.2.0)(react@18.2.0)
next-auth:
- specifier: 5.0.0-beta.4
- version: 5.0.0-beta.4(next@14.1.4)(react@18.2.0)
+ specifier: 5.0.0-beta.16
+ version: 5.0.0-beta.16(next@14.1.4)(react@18.2.0)
next-intl:
specifier: ^3.11.1
version: 3.11.1(next@14.1.4)(react@18.2.0)
@@ -595,15 +595,22 @@ packages:
'@jridgewell/trace-mapping': 0.3.25
dev: false
- /@auth/core@0.18.4:
- resolution: {integrity: sha512-GsNhsP1xE/3FoNS3dVkPjqRljLNJ4iyL2OLv3klQGNvw3bMpROFcK4lqhx7+pPHiamnVaYt2vg1xbB+lsNaevg==}
+ /@auth/core@0.28.1:
+ resolution: {integrity: sha512-gvp74mypYZADpTlfGRp6HE0G3pIHWvtJpy+KZ+8FvY0cmlIpHog+jdMOdd29dQtLtN25kF2YbfHsesCFuGUQbg==}
peerDependencies:
+ '@simplewebauthn/browser': ^9.0.1
+ '@simplewebauthn/server': ^9.0.2
nodemailer: ^6.8.0
peerDependenciesMeta:
+ '@simplewebauthn/browser':
+ optional: true
+ '@simplewebauthn/server':
+ optional: true
nodemailer:
optional: true
dependencies:
'@panva/hkdf': 1.1.1
+ '@types/cookie': 0.6.0
cookie: 0.6.0
jose: 5.1.3
oauth4webapi: 2.4.0
@@ -5709,7 +5716,6 @@ packages:
/@types/cookie@0.6.0:
resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==}
- dev: true
/@types/cross-spawn@6.0.6:
resolution: {integrity: sha512-fXRhhUkG4H3TQk5dBhQ7m/JDdSNHKwR2BBia62lhwEIq9xGiQKLxd6LymNhn47SjXhsUEPmxi+PKw2OkW4LLjA==}
@@ -11140,17 +11146,23 @@ packages:
/neo-async@2.6.2:
resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
- /next-auth@5.0.0-beta.4(next@14.1.4)(react@18.2.0):
- resolution: {integrity: sha512-vgocjvwPA8gxd/zrIP/vr9lJ/HeNe+C56lPP1D3sdyenHt8KncQV6ro7q0xCsDp1fcOKx7WAWVZH5o8aMxDzgw==}
+ /next-auth@5.0.0-beta.16(next@14.1.4)(react@18.2.0):
+ resolution: {integrity: sha512-dX2snB+ezN23tFzSes3n3uosT9iBf0eILPYWH/R2fd9n3ZzdMQlRzq7JIOPeS1aLc84IuRlyuyXyx9XmmZB6og==}
peerDependencies:
+ '@simplewebauthn/browser': ^9.0.1
+ '@simplewebauthn/server': ^9.0.2
next: ^14
nodemailer: ^6.6.5
react: ^18.2.0
peerDependenciesMeta:
+ '@simplewebauthn/browser':
+ optional: true
+ '@simplewebauthn/server':
+ optional: true
nodemailer:
optional: true
dependencies:
- '@auth/core': 0.18.4
+ '@auth/core': 0.28.1
next: 14.1.4(@babel/core@7.24.4)(react-dom@18.2.0)(react@18.2.0)
react: 18.2.0
dev: false