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

Conversation

thomasballinger
Copy link
Contributor

Make the Next.js middleware function isAuthenticated fail 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.

Copy link

vercel bot commented Dec 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
convex-auth-docs ✅ Ready (Inspect) Visit Preview Dec 20, 2024 10:07pm

CHANGELOG.md Outdated
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.78
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is unreleased too, I think - I just speculatively added the next version # when I updated this file earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah gotcha

Copy link
Collaborator

@dowski dowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, but see other comments.

"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",
);
}
throw e;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to return false here. Otherwise errors like sending an invalid JWT to the Convex backend will also throw (which is why that one test is failing, I think).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray for tests!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah for the token expired and invalid token cases, got it. Maybe we can pick those out too, for now I'll log whatever error it is.

Copy link

pkg-pr-new bot commented Dec 19, 2024

npm i https://pkg.pr.new/get-convex/convex-auth/@convex-dev/auth@144

commit: e536901

@thomasballinger thomasballinger merged commit 66e1197 into main Dec 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants