Skip to content

feat(nextjs): Replace redirectUrl of protect with unauthorizedUrl and unauthenticatedUrl#2672

Merged
nikosdouvlis merged 3 commits into
mainfrom
elef/replace-redirect-url-protect
Feb 1, 2024
Merged

feat(nextjs): Replace redirectUrl of protect with unauthorizedUrl and unauthenticatedUrl#2672
nikosdouvlis merged 3 commits into
mainfrom
elef/replace-redirect-url-protect

Conversation

@panteliselef

Copy link
Copy Markdown
Contributor

Description

This affects the public signature of auth().protect()

How to use

- auth().protect({redirectUrl: '/sign-in'}) 
+ auth().protect({unauthenticatedUrl: '/sign-in'}) 


- auth().protect({role: 'org:admin'},{redirectUrl: '/sign-in'}) 
+ auth().protect({role: 'org:admin'},{unauthenticatedUrl: '/sign-in', unauthorizedUrl: '/discover'}) 

Checklist

  • npm test runs as expected.
  • npm run 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:

Packages affected

  • @clerk/backend
  • @clerk/chrome-extension
  • @clerk/clerk-js
  • @clerk/clerk-expo
  • @clerk/fastify
  • gatsby-plugin-clerk
  • @clerk/localizations
  • @clerk/nextjs
  • @clerk/clerk-react
  • @clerk/remix
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/themes
  • @clerk/types
  • build/tooling/chore

@panteliselef panteliselef self-assigned this Jan 29, 2024
@changeset-bot

changeset-bot Bot commented Jan 29, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 095c396

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

This PR includes changesets to release 2 packages
Name Type
@clerk/nextjs Minor
@clerk/elements Patch

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

import { SIGN_IN_URL } from './constants';

type AuthProtectOptions = { redirectUrl?: string };
type AuthProtectOptions = { unauthorizedUrl?: string; unauthenticatedUrl?: string };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went with unauthenticatedUrl instead of signInUrl. I'm not opinionated about this we can go with the initial naming.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@nikosdouvlis now that i'm thinking about it, we may still need to do signInUrl because of the env variables right ?

@nikosdouvlis nikosdouvlis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

@nikosdouvlis nikosdouvlis merged commit c7d960c into main Feb 1, 2024
@nikosdouvlis nikosdouvlis deleted the elef/replace-redirect-url-protect branch February 1, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants