Skip to content

Commit 9bf9289

Browse files
committed
chore: Improve payload api types for /me and /refresh-token endpoints
1 parent a6fb756 commit 9bf9289

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/payload-authjs/src/payload/session/PayloadSessionProvider.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type { CollectionSlug, DataFromCollectionSlug } from "payload";
44
import { createContext, type ReactNode, useCallback, useEffect, useState } from "react";
5+
import type { AUTHJS_STRATEGY_NAME } from "../AuthjsAuthStrategy";
56
import type { PayloadSession } from "./getPayloadSession";
67

78
export interface SessionContext<TSlug extends CollectionSlug> {
@@ -74,7 +75,12 @@ export const PayloadSessionProvider = <TSlug extends CollectionSlug = "users">({
7475
signal,
7576
});
7677
const result: {
77-
user: DataFromCollectionSlug<TSlug> | null;
78+
user:
79+
| ({
80+
collection?: CollectionSlug;
81+
_strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string);
82+
} & DataFromCollectionSlug<TSlug>)
83+
| null;
7884
exp: number;
7985
collection?: CollectionSlug;
8086
/**
@@ -137,7 +143,12 @@ export const PayloadSessionProvider = <TSlug extends CollectionSlug = "users">({
137143
method: "POST",
138144
});
139145
const result: {
140-
user: DataFromCollectionSlug<TSlug> | null;
146+
user:
147+
| ({
148+
collection?: CollectionSlug;
149+
_strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string);
150+
} & DataFromCollectionSlug<TSlug>)
151+
| null;
141152
exp: number /**
142153
* @deprecated Use user._strategy instead
143154
*

packages/payload-authjs/src/payload/session/getPayloadSession.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ export const getPayloadSession = cache(
5050
},
5151
});
5252
const result: {
53-
user: DataFromCollectionSlug<TSlug> | null;
53+
user:
54+
| ({
55+
collection?: CollectionSlug;
56+
_strategy?: typeof AUTHJS_STRATEGY_NAME | "local-jwt" | "api-key" | ({} & string);
57+
} & DataFromCollectionSlug<TSlug>)
58+
| null;
5459
exp: number;
5560
collection?: CollectionSlug;
5661
/**

0 commit comments

Comments
 (0)