Skip to content

Commit b1da0e4

Browse files
authored
feat: use payload's token extraction logic (#48)
1 parent 40afea8 commit b1da0e4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/auth-strategy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
AuthStrategyResult,
66
CollectionSlug,
77
User,
8-
parseCookies,
8+
extractJWT,
99
} from "payload";
1010
import { PluginOptions } from "./types";
1111

@@ -17,8 +17,7 @@ export const createAuthStrategy = (
1717
name: pluginOptions.strategyName,
1818
authenticate: async ({ headers, payload }): Promise<AuthStrategyResult> => {
1919
try {
20-
const cookie = parseCookies(headers);
21-
const token = cookie.get(`${payload.config.cookiePrefix}-token`);
20+
const token = extractJWT({ headers, payload })
2221
if (!token) return { user: null };
2322

2423
let jwtUser: JWTPayload | null = null;

0 commit comments

Comments
 (0)