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

Implement organization creation permission controls #1373

Merged
merged 6 commits into from
Jun 19, 2023

Conversation

jescalan
Copy link
Contributor

Type of change

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

Packages affected

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

Description

If the "user can create organizations" permission is false, the "create organization" button will not appear in the OrganizationSwitcher component.

@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2023

🦋 Changeset detected

Latest commit: 8c0cf20

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

This PR includes changesets to release 12 packages
Name Type
@clerk/clerk-js Minor
@clerk/types Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node 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

@@ -80,6 +80,7 @@ export class User extends BaseResource implements UserResource {
publicMetadata: UserPublicMetadata = {};
unsafeMetadata: UserUnsafeMetadata = {};
lastSignInAt: Date | null = null;
createOrganizationEnabled = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we actually default this to false?

Copy link
Member

Choose a reason for hiding this comment

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

It shouldn't matter in this case as a User is always initialized from json data.

You definitely have more context than me,but this seems fine!

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

@jescalan jescalan force-pushed the je.permission-gate-org-creation branch from 5274f30 to 3c2c4e3 Compare June 16, 2023 21:11
@@ -83,14 +83,14 @@ export type Attributes = {
};

export type Actions = {
delete_self: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was not, but tests failed because of it, and fixed now!

@jescalan jescalan force-pushed the je.permission-gate-org-creation branch from 64fd8e5 to 6a4bc3f Compare June 17, 2023 19:16
@@ -101,7 +102,6 @@ export interface UserSettingsJSON extends ClerkResourceJSON {
sign_in: SignInData;
sign_up: SignUpData;
password_settings: PasswordSettingsData;
actions: Actions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just a move to make the placement consistent between the resource and json types

@jescalan jescalan requested a review from mzhong9723 June 17, 2023 19:22
@jescalan jescalan force-pushed the je.permission-gate-org-creation branch 3 times, most recently from 9754384 to 28266a4 Compare June 19, 2023 16:22
@jescalan jescalan force-pushed the je.permission-gate-org-creation branch from 28266a4 to 422c167 Compare June 19, 2023 16:27
@jescalan jescalan merged commit 1195481 into main Jun 19, 2023
9 checks passed
@jescalan jescalan deleted the je.permission-gate-org-creation branch June 19, 2023 16:45
@clerk-cookie clerk-cookie mentioned this pull request Jun 19, 2023
mikestopcontinues pushed a commit to mikestopcontinues/clerk-javascript that referenced this pull request Jun 28, 2023
* feat(clerk-js): Hide 'create organization' button in org switcher if no permissions
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants