mirror of
https://github.com/vercel/commerce.git
synced 2025-06-28 01:11:24 +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) {
|
export async function GET(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const session = await getServerSession(authOptions);
|
const session = await getServerSession(authOptions);
|
||||||
if (!session?.user?.store_id) {
|
if (!session?.user?.customer_id) {
|
||||||
return NextResponse.json({ error: 'User not logged' }, { status: 401 });
|
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 });
|
return NextResponse.json(customer, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return NextResponse.json({ error: JSON.stringify(error) }, { status: 500 });
|
return NextResponse.json({ error: JSON.stringify(error) }, { status: 500 });
|
||||||
|
@ -9,7 +9,7 @@ import Link from 'next/link';
|
|||||||
export default async function OrdersPage() {
|
export default async function OrdersPage() {
|
||||||
const t = await getTranslations('ProfilePage');
|
const t = await getTranslations('ProfilePage');
|
||||||
const data = await getServerSession(authOptions);
|
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 (
|
return (
|
||||||
<section className="mt-4 grid w-full gap-4 px-4 pb-4">
|
<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() {
|
export default async function PersonalArea() {
|
||||||
const session = await getServerSession(authOptions);
|
const session = await getServerSession(authOptions);
|
||||||
const t = await getTranslations('ProfilePage');
|
const t = await getTranslations('ProfilePage');
|
||||||
if (!session?.user?.store_id) {
|
if (!session?.user?.customer_id) {
|
||||||
return { status: 401, body: { error: 'User not logged' } };
|
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 (
|
return (
|
||||||
<section className="mt-4 grid max-w-screen-2xl gap-4 px-4 pb-4">
|
<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' {
|
declare module 'next-auth' {
|
||||||
interface Session {
|
interface Session {
|
||||||
user: {
|
user: {
|
||||||
store_id: number;
|
customer_id: number;
|
||||||
token: string;
|
token: string;
|
||||||
user_email: string;
|
user_email: string;
|
||||||
user_nicename: string;
|
user_nicename: string;
|
||||||
@ -13,7 +13,7 @@ declare module 'next-auth' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface User {
|
interface User {
|
||||||
store_id: number;
|
customer_id: number;
|
||||||
token: string;
|
token: string;
|
||||||
user_email: string;
|
user_email: string;
|
||||||
user_nicename: string;
|
user_nicename: string;
|
||||||
@ -24,7 +24,7 @@ declare module 'next-auth' {
|
|||||||
declare module 'next-auth/jwt' {
|
declare module 'next-auth/jwt' {
|
||||||
interface JWT {
|
interface JWT {
|
||||||
user: {
|
user: {
|
||||||
store_id: number;
|
customer_id: number;
|
||||||
token: string;
|
token: string;
|
||||||
user_email: string;
|
user_email: string;
|
||||||
user_nicename: string;
|
user_nicename: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user