Skip to content

Commit

Permalink
Make isAuthenticated in middleware fail more loudly. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasballinger authored Dec 20, 2024
1 parent e6cbdc6 commit 66e1197
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Changelog

## 0.0.78
## Unreleased

- Add support for
[custom OAuth callback and sign-in URLs](https://labs.convex.dev/auth/advanced#custom-callback-and-sign-in-urls)

- Next.js middleware function `isAuthenticated` fails more loudly; previously it
returned false in the case of a Convex backend that didn't expose an endpoint
called `auth:isAuthenticated`, now it throws an error. This should help people
with the migration required for 0.0.76.

## 0.0.77

- Fix syntax of an import to work with convex-test.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/nextjs/server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ async function isAuthenticated(token: string | null): Promise<boolean> {
{},
{ token: token },
);
} catch {
} catch (e: any) {
if (e.message.includes("Could not find public function")) {
throw new Error(
"Server Error: could not find api.auth.isAuthenticated. convex-auth 0.0.76 introduced a new export in convex/auth.ts. Add `isAuthenticated` to the list of functions returned from convexAuth(). See convex-auth changelog for more https://github.com/get-convex/convex-auth/blob/main/CHANGELOG.md",
);
} else {
console.log("Returning false from isAuthenticated because", e);
}
return false;
}
}
2 changes: 1 addition & 1 deletion test-nextjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66e1197

Please sign in to comment.