Skip to content

feat(astro): Support auth().redirectToSignIn() at page level - #3711

Merged
panteliselef merged 3 commits into
mainfrom
elef/eco-41-support-authredirecttosignin-at-page-level
Jul 15, 2024
Merged

feat(astro): Support auth().redirectToSignIn() at page level#3711
panteliselef merged 3 commits into
mainfrom
elef/eco-41-support-authredirecttosignin-at-page-level

Conversation

@panteliselef

@panteliselef panteliselef commented Jul 15, 2024

Copy link
Copy Markdown
Contributor

Description

Support Astro.locals.auth().redirectToSignIn()
This allows for redirectingToSignIn at the page level and provides parity with Nextjs.

Note: We are not exposing auth().protect() because DX is taking a hit, because we cannot just throw a response in astro, we need to return it. And we are not including protect at the middleware level so we don't confuse people that would expect it to work at page level.

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:

@panteliselef panteliselef self-assigned this Jul 15, 2024
@changeset-bot

changeset-bot Bot commented Jul 15, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b8a3353

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

This PR includes changesets to release 1 package
Name Type
@clerk/astro 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

@panteliselef
panteliselef requested review from LekoArts, dimkl, nikosdouvlis and wobsoriano and removed request for dimkl July 15, 2024 12:14
Comment on lines +250 to +251
}).redirectToSignIn({
returnBackUrl: opts.returnBackUrl === null ? '' : opts.returnBackUrl || clerkUrl.toString(),

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.

Does the redirectToSignUp function commonly used?

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.

We've build it, but no public API consumes it. and this implementation aims to mirror the API from @clerk/nextjs.

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.

Thanks for answering!

@wobsoriano wobsoriano 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.

Looks straightforward, just left a question 🚀

@panteliselef
panteliselef enabled auto-merge (squash) July 15, 2024 15:58
@panteliselef
panteliselef merged commit 81d3cdd into main Jul 15, 2024
@panteliselef
panteliselef deleted the elef/eco-41-support-authredirecttosignin-at-page-level branch July 15, 2024 16:30
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.

3 participants