Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump next-auth from 5.0.0-beta.4 to 5.0.0-beta.16 #740

Merged
merged 2 commits into from
Apr 8, 2024
Merged
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
7 changes: 7 additions & 0 deletions .changeset/short-cycles-learn.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useRouter } from '~/navigation';
import { submitChangePasswordForm } from '../_actions/submit-change-password-form';

interface Props {
customerId: number;
customerId: string;
customerToken: string;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/core/app/[locale]/(default)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function Login({ params: { locale }, searchParams }: Props)
<div className="mx-auto my-6 max-w-4xl">
<h2 className="mb-8 text-4xl font-black lg:text-5xl">{t('changePasswordHeading')}</h2>
<NextIntlClientProvider locale={locale} messages={{ Account }}>
<ChangePasswordForm customerId={Number(customerId)} customerToken={customerToken} />
<ChangePasswordForm customerId={customerId} customerToken={customerToken} />
</NextIntlClientProvider>
</div>
);
Expand Down
26 changes: 7 additions & 19 deletions apps/core/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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;
},
Expand All @@ -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) {
Expand Down Expand Up @@ -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 };
2 changes: 1 addition & 1 deletion apps/core/client/mutations/apply-checkout-coupon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const applyCheckoutCoupon = async (checkoutEntityId: string, couponCode:
},
},
},
customerId: Number(customerId),
customerId,
fetchOptions: { cache: 'no-store' },
});

Expand Down
2 changes: 1 addition & 1 deletion apps/core/client/mutations/assign-cart-to-customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const assignCartToCustomer = async (customerId: string, cartEntityId: Car
cartEntityId,
},
},
customerId: Number(customerId),
customerId,
fetchOptions: { cache: 'no-store' },
});

Expand Down
2 changes: 1 addition & 1 deletion apps/core/client/mutations/unapply-checkout-coupon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const unapplyCheckoutCoupon = async (checkoutEntityId: string, couponCode
},
},
},
customerId: Number(customerId),
customerId,
fetchOptions: { cache: 'no-store' },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const unassignCartFromCustomer = async (
cartEntityId,
},
},
customerId: Number(customerId),
customerId,
fetchOptions: { cache: 'no-store' },
});

Expand Down
2 changes: 1 addition & 1 deletion apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class Client<FetcherRequestInit extends RequestInit = RequestInit> {
async fetch<TResult, TVariables extends Record<string, unknown>>(config: {
document: DocumentDecoration<TResult, TVariables>;
variables: TVariables;
customerId?: number;
customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise<BigCommerceResponse<TResult>>;

// Overload for documents that do not require variables
async fetch<TResult>(config: {
document: DocumentDecoration<TResult, Record<string, never>>;
variables?: undefined;
customerId?: number;
customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise<BigCommerceResponse<TResult>>;

Expand All @@ -57,7 +57,7 @@ class Client<FetcherRequestInit extends RequestInit = RequestInit> {
}: {
document: DocumentDecoration<TResult, TVariables>;
variables?: TVariables;
customerId?: number;
customerId?: string;
fetchOptions?: FetcherRequestInit;
}): Promise<BigCommerceResponse<TResult>> {
const { cache, headers = {}, ...rest } = fetchOptions;
Expand All @@ -70,7 +70,7 @@ class Client<FetcherRequestInit extends RequestInit = RequestInit> {
'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({
Expand Down
28 changes: 20 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading