mirror of
https://github.com/vercel/commerce.git
synced 2025-06-27 17:01:21 +00:00
fix: custom id jwt token
This commit is contained in:
parent
2345a83215
commit
150d361791
@ -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 });
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
6
types/next-auth.d.ts
vendored
6
types/next-auth.d.ts
vendored
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user