Skip to content

Commit

Permalink
make jwt payload parsing less strict
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 9, 2024
1 parent 922320e commit ce724eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/ui/docs-bundle/src/server/auth/FernJWT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export async function verifyFernJWT(token: string, secret?: string, issuer?: str
const verified = await jwtVerify(token, getJwtTokenSecret(secret), {
issuer: issuer ?? "https://buildwithfern.com",
});
return FernUserSchema.parse(verified.payload.fern);
// if the token is undefined, FernUser will be an empty object
return FernUserSchema.optional().parse(verified.payload.fern) ?? {};
}

export async function verifyFernJWTConfig(token: string, authConfig: AuthEdgeConfig | undefined): Promise<FernUser> {
Expand Down

0 comments on commit ce724eb

Please sign in to comment.