fix: custom id jwt token

This commit is contained in:
paolosantarsiero 2025-02-07 12:25:04 +01:00
parent 2345a83215
commit 150d361791
4 changed files with 8 additions and 8 deletions

View File

@ -6,10 +6,10 @@ import { NextRequest, NextResponse } from 'next/server';
export async function GET(req: NextRequest) {
try {
const session = await getServerSession(authOptions);
if (!session?.user?.store_id) {
if (!session?.user?.customer_id) {
return NextResponse.json({ error: 'User not logged' }, { status: 401 });
}
const customer = await woocommerce.get('customers', { id: session?.user.store_id });
const customer = await woocommerce.get('customers', { id: session?.user.customer_id });
return NextResponse.json(customer, { status: 200 });
} catch (error) {
return NextResponse.json({ error: JSON.stringify(error) }, { status: 500 });

View File

@ -9,7 +9,7 @@ import Link from 'next/link';
export default async function OrdersPage() {
const t = await getTranslations('ProfilePage');
const data = await getServerSession(authOptions);
const orders = await woocommerce.get('orders', { customer: data?.user?.store_id });
const orders = await woocommerce.get('orders', { customer: data?.user?.customer_id });
return (
<section className="mt-4 grid w-full gap-4 px-4 pb-4">

View File

@ -8,11 +8,11 @@ import { getTranslations } from 'next-intl/server';
export default async function PersonalArea() {
const session = await getServerSession(authOptions);
const t = await getTranslations('ProfilePage');
if (!session?.user?.store_id) {
if (!session?.user?.customer_id) {
return { status: 401, body: { error: 'User not logged' } };
}
const customer = await woocommerce.get('customers', { id: session?.user.store_id });
const customer = await woocommerce.get('customers', { id: session?.user.customer_id });
return (
<section className="mt-4 grid max-w-screen-2xl gap-4 px-4 pb-4">

View File

@ -4,7 +4,7 @@ import 'next-auth/jwt';
declare module 'next-auth' {
interface Session {
user: {
store_id: number;
customer_id: number;
token: string;
user_email: string;
user_nicename: string;
@ -13,7 +13,7 @@ declare module 'next-auth' {
}
interface User {
store_id: number;
customer_id: number;
token: string;
user_email: string;
user_nicename: string;
@ -24,7 +24,7 @@ declare module 'next-auth' {
declare module 'next-auth/jwt' {
interface JWT {
user: {
store_id: number;
customer_id: number;
token: string;
user_email: string;
user_nicename: string;