Skip to content

Commit

Permalink
Bump auth version
Browse files Browse the repository at this point in the history
  • Loading branch information
sshader committed Jan 14, 2025
1 parent 2da5c1d commit ea9e95b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 78 deletions.
2 changes: 1 addition & 1 deletion convex/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { convexAuth } from "@convex-dev/auth/server";
import Google from "@auth/core/providers/google";

export const { auth, signIn, signOut, store } = convexAuth({
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [Google],
});
7 changes: 4 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ const isSignInPage = createRouteMatcher(["/signin"]);
const isProtectedRoute = createRouteMatcher(["/product(.*)"]);

export default convexAuthNextjsMiddleware(
(request, { convexAuth }) => {
if (isSignInPage(request) && convexAuth.isAuthenticated()) {
async (request, { convexAuth }) => {
const isAuthenticated = await convexAuth.isAuthenticated();
if (isSignInPage(request) && isAuthenticated) {
return nextjsMiddlewareRedirect(request, "/product");
}
if (isProtectedRoute(request) && !convexAuth.isAuthenticated()) {
if (isProtectedRoute(request) && !isAuthenticated) {
return nextjsMiddlewareRedirect(request, "/signin");
}
},
Expand Down
123 changes: 51 additions & 72 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"testFunctions": "node backendHarness.js 'npm run testFunctionsExistingBackend'"
},
"dependencies": {
"@auth/core": "^0.34.2",
"@convex-dev/auth": "^0.0.71-alpha.0",
"@auth/core": "^0.37.0",
"@convex-dev/aggregate": "^0.1.12",
"@convex-dev/auth": "^0.0.80",
"chess.js": "^1.0.0-beta.3",
"convex": "^1.16.3",
"convex-helpers": "^0.1.25",
Expand Down

0 comments on commit ea9e95b

Please sign in to comment.