Skip to content

Conversation

@LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Apr 2, 2025

Description

Resolves ORGS-622

Deprecate event.context.auth in favor of event.context.auth():

export default clerkMiddleware((event) => {
+ const { userId } = event.context.auth()
- const { userId } = event.context.auth
  const isAdminRoute = event.path.startsWith('/api/admin')

  if (!userId && isAdminRoute) {
    throw createError({
      statusCode: 401,
      statusMessage: 'Unauthorized: User not signed in',
    })
  }
})

This change is needed for an upcoming feature in which options are passed to auth: auth({ treatPendingAsSignedOn })

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@LauraBeatris LauraBeatris self-assigned this Apr 2, 2025
@changeset-bot
Copy link

changeset-bot bot commented Apr 2, 2025

🦋 Changeset detected

Latest commit: ffb0210

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nuxt Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Apr 2, 2025

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

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2025 6:17pm

@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from 13fbb72 to a5a0837 Compare April 2, 2025 16:56
@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from a5a0837 to 04d793c Compare April 2, 2025 16:57
@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.17-snapshot.v20250402165855
@clerk/astro 2.4.6-snapshot.v20250402165855
@clerk/backend 1.26.0-snapshot.v20250402165855
@clerk/chrome-extension 2.2.24-snapshot.v20250402165855
@clerk/clerk-js 5.59.0-snapshot.v20250402165855
@clerk/elements 0.23.9-snapshot.v20250402165855
@clerk/clerk-expo 2.9.7-snapshot.v20250402165855
@clerk/expo-passkeys 0.2.1-snapshot.v20250402165855
@clerk/express 1.3.60-snapshot.v20250402165855
@clerk/fastify 2.1.33-snapshot.v20250402165855
@clerk/localizations 3.13.5-snapshot.v20250402165855
@clerk/nextjs 6.12.13-snapshot.v20250402165855
@clerk/nuxt 1.5.0-snapshot.v20250402165855
@clerk/clerk-react 5.25.6-snapshot.v20250402165855
@clerk/react-router 1.1.12-snapshot.v20250402165855
@clerk/remix 4.5.12-snapshot.v20250402165855
@clerk/shared 3.3.0-snapshot.v20250402165855
@clerk/tanstack-react-start 0.12.3-snapshot.v20250402165855
@clerk/testing 1.4.34-snapshot.v20250402165855
@clerk/themes 2.2.27-snapshot.v20250402165855
@clerk/types 4.50.2-snapshot.v20250402165855
@clerk/vue 1.4.6-snapshot.v20250402165855

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402165855 --save-exact

@clerk/astro

npm i @clerk/astro@2.4.6-snapshot.v20250402165855 --save-exact

@clerk/backend

npm i @clerk/backend@1.26.0-snapshot.v20250402165855 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402165855 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.59.0-snapshot.v20250402165855 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.9-snapshot.v20250402165855 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402165855 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402165855 --save-exact

@clerk/express

npm i @clerk/express@1.3.60-snapshot.v20250402165855 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.1.33-snapshot.v20250402165855 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.13.5-snapshot.v20250402165855 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.12.13-snapshot.v20250402165855 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.5.0-snapshot.v20250402165855 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.25.6-snapshot.v20250402165855 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.1.12-snapshot.v20250402165855 --save-exact

@clerk/remix

npm i @clerk/remix@4.5.12-snapshot.v20250402165855 --save-exact

@clerk/shared

npm i @clerk/shared@3.3.0-snapshot.v20250402165855 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402165855 --save-exact

@clerk/testing

npm i @clerk/testing@1.4.34-snapshot.v20250402165855 --save-exact

@clerk/themes

npm i @clerk/themes@2.2.27-snapshot.v20250402165855 --save-exact

@clerk/types

npm i @clerk/types@4.50.2-snapshot.v20250402165855 --save-exact

@clerk/vue

npm i @clerk/vue@1.4.6-snapshot.v20250402165855 --save-exact

@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.17-snapshot.v20250402171054
@clerk/astro 2.4.6-snapshot.v20250402171054
@clerk/backend 1.26.0-snapshot.v20250402171054
@clerk/chrome-extension 2.2.24-snapshot.v20250402171054
@clerk/clerk-js 5.59.0-snapshot.v20250402171054
@clerk/elements 0.23.9-snapshot.v20250402171054
@clerk/clerk-expo 2.9.7-snapshot.v20250402171054
@clerk/expo-passkeys 0.2.1-snapshot.v20250402171054
@clerk/express 1.3.60-snapshot.v20250402171054
@clerk/fastify 2.1.33-snapshot.v20250402171054
@clerk/localizations 3.13.5-snapshot.v20250402171054
@clerk/nextjs 6.12.13-snapshot.v20250402171054
@clerk/nuxt 1.5.0-snapshot.v20250402171054
@clerk/clerk-react 5.25.6-snapshot.v20250402171054
@clerk/react-router 1.1.12-snapshot.v20250402171054
@clerk/remix 4.5.12-snapshot.v20250402171054
@clerk/shared 3.3.0-snapshot.v20250402171054
@clerk/tanstack-react-start 0.12.3-snapshot.v20250402171054
@clerk/testing 1.4.34-snapshot.v20250402171054
@clerk/themes 2.2.27-snapshot.v20250402171054
@clerk/types 4.50.2-snapshot.v20250402171054
@clerk/vue 1.4.6-snapshot.v20250402171054

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402171054 --save-exact

@clerk/astro

npm i @clerk/astro@2.4.6-snapshot.v20250402171054 --save-exact

@clerk/backend

npm i @clerk/backend@1.26.0-snapshot.v20250402171054 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402171054 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.59.0-snapshot.v20250402171054 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.9-snapshot.v20250402171054 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402171054 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402171054 --save-exact

@clerk/express

npm i @clerk/express@1.3.60-snapshot.v20250402171054 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.1.33-snapshot.v20250402171054 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.13.5-snapshot.v20250402171054 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.12.13-snapshot.v20250402171054 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.5.0-snapshot.v20250402171054 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.25.6-snapshot.v20250402171054 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.1.12-snapshot.v20250402171054 --save-exact

@clerk/remix

npm i @clerk/remix@4.5.12-snapshot.v20250402171054 --save-exact

@clerk/shared

npm i @clerk/shared@3.3.0-snapshot.v20250402171054 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402171054 --save-exact

@clerk/testing

npm i @clerk/testing@1.4.34-snapshot.v20250402171054 --save-exact

@clerk/themes

npm i @clerk/themes@2.2.27-snapshot.v20250402171054 --save-exact

@clerk/types

npm i @clerk/types@4.50.2-snapshot.v20250402171054 --save-exact

@clerk/vue

npm i @clerk/vue@1.4.6-snapshot.v20250402171054 --save-exact

@LauraBeatris
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @LauraBeatris - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.0.17-snapshot.v20250402174132
@clerk/astro 2.4.6-snapshot.v20250402174132
@clerk/backend 1.26.0-snapshot.v20250402174132
@clerk/chrome-extension 2.2.24-snapshot.v20250402174132
@clerk/clerk-js 5.59.0-snapshot.v20250402174132
@clerk/elements 0.23.9-snapshot.v20250402174132
@clerk/clerk-expo 2.9.7-snapshot.v20250402174132
@clerk/expo-passkeys 0.2.1-snapshot.v20250402174132
@clerk/express 1.3.60-snapshot.v20250402174132
@clerk/fastify 2.1.33-snapshot.v20250402174132
@clerk/localizations 3.13.5-snapshot.v20250402174132
@clerk/nextjs 6.12.13-snapshot.v20250402174132
@clerk/nuxt 1.5.0-snapshot.v20250402174132
@clerk/clerk-react 5.25.6-snapshot.v20250402174132
@clerk/react-router 1.1.12-snapshot.v20250402174132
@clerk/remix 4.5.12-snapshot.v20250402174132
@clerk/shared 3.3.0-snapshot.v20250402174132
@clerk/tanstack-react-start 0.12.3-snapshot.v20250402174132
@clerk/testing 1.4.34-snapshot.v20250402174132
@clerk/themes 2.2.27-snapshot.v20250402174132
@clerk/types 4.50.2-snapshot.v20250402174132
@clerk/vue 1.4.6-snapshot.v20250402174132

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/agent-toolkit@0.0.17-snapshot.v20250402174132 --save-exact

@clerk/astro

npm i @clerk/astro@2.4.6-snapshot.v20250402174132 --save-exact

@clerk/backend

npm i @clerk/backend@1.26.0-snapshot.v20250402174132 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.2.24-snapshot.v20250402174132 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.59.0-snapshot.v20250402174132 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.9-snapshot.v20250402174132 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.9.7-snapshot.v20250402174132 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.2.1-snapshot.v20250402174132 --save-exact

@clerk/express

npm i @clerk/express@1.3.60-snapshot.v20250402174132 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.1.33-snapshot.v20250402174132 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.13.5-snapshot.v20250402174132 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.12.13-snapshot.v20250402174132 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.5.0-snapshot.v20250402174132 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.25.6-snapshot.v20250402174132 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.1.12-snapshot.v20250402174132 --save-exact

@clerk/remix

npm i @clerk/remix@4.5.12-snapshot.v20250402174132 --save-exact

@clerk/shared

npm i @clerk/shared@3.3.0-snapshot.v20250402174132 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.12.3-snapshot.v20250402174132 --save-exact

@clerk/testing

npm i @clerk/testing@1.4.34-snapshot.v20250402174132 --save-exact

@clerk/themes

npm i @clerk/themes@2.2.27-snapshot.v20250402174132 --save-exact

@clerk/types

npm i @clerk/types@4.50.2-snapshot.v20250402174132 --save-exact

@clerk/vue

npm i @clerk/vue@1.4.6-snapshot.v20250402174132 --save-exact

@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from 54fc6b1 to c20a798 Compare April 2, 2025 17:50
@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from c20a798 to 4a3cb7d Compare April 2, 2025 17:50
@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from 4a3cb7d to d19689a Compare April 2, 2025 17:50
@LauraBeatris LauraBeatris requested a review from a team April 2, 2025 17:57
@LauraBeatris LauraBeatris marked this pull request as ready for review April 2, 2025 17:57
@LauraBeatris LauraBeatris force-pushed the laura/nuxt-auth-as-func branch from d19689a to 8c5ebcc Compare April 2, 2025 17:57
@LauraBeatris LauraBeatris requested a review from wobsoriano April 2, 2025 17:58

const authObject = requestState.toAuth();
event.context.auth = authObject;
const authHandler = () => authObject;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm planning to raise another PR after shipping this one, which it'll introduce some parameters to this authHandler

That's the whole reason we're doing this change as well, so having a function allow to perform custom logic against the auth object

Copy link
Member

@wobsoriano wobsoriano Apr 2, 2025

Choose a reason for hiding this comment

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

Can we add the same code example we have in the description here?

Copy link
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

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

Looks great here!

@LauraBeatris LauraBeatris merged commit e71b609 into main Apr 2, 2025
30 checks passed
@LauraBeatris LauraBeatris deleted the laura/nuxt-auth-as-func branch April 2, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants