Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make isAuthenticated in middleware fail more loudly. #144

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading