Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

revert the restrictions

Kiran Kaeccc95b61a0
diff --git a/apps/web/app/api/tokens/route.ts b/apps/web/app/api/tokens/route.ts
index c28d8babbc..5b5c1fb1e1 100644
--- a/apps/web/app/api/tokens/route.ts
+++ b/apps/web/app/api/tokens/route.ts
@@ -67,14 +67,6 @@ export const POST = withWorkspace(
},
});
- // Only workspace owners can create machine users
- if (isMachine && role !== "owner") {
- throw new DubApiError({
- code: "bad_request",
- message: "Only workspace owners can create machine users.",
- });
- }
-
if (!validateScopesForRole(scopes || [], role)) {
throw new DubApiError({
code: "unprocessable_entity",
diff --git a/apps/web/lib/auth/workspace-edge.ts b/apps/web/lib/auth/workspace-edge.ts
index d97520a00f..89f88a2837 100644
--- a/apps/web/lib/auth/workspace-edge.ts
+++ b/apps/web/lib/auth/workspace-edge.ts
@@ -258,10 +258,7 @@ export const withWorkspaceEdge = (
}
// By default, the user has access to all permissions based on their role
- // Machine users have owner role by default
- permissions = getPermissionsByRole(
- session.user.isMachine ? "owner" : workspace.users[0].role,
- );
+ permissions = getPermissionsByRole(workspace.users[0].role);
// Find the subset of permissions that the user has access to based on the token scopes
if (isRestrictedToken) {
diff --git a/apps/web/lib/auth/workspace.ts b/apps/web/lib/auth/workspace.ts
index a6ec448a20..4796abb53f 100644
--- a/apps/web/lib/auth/workspace.ts
+++ b/apps/web/lib/auth/workspace.ts
@@ -283,10 +283,7 @@ export const withWorkspace = (
}
// By default, the user has access to all permissions based on their role
- // Machine users have owner role by default
- permissions = getPermissionsByRole(
- session.user.isMachine ? "owner" : workspace.users[0].role,
- );
+ permissions = getPermissionsByRole(workspace.users[0].role);
// Find the subset of permissions that the user has access to based on the token scopes
if (isRestrictedToken) {
diff --git a/apps/web/ui/modals/add-edit-token-modal.tsx b/apps/web/ui/modals/add-edit-token-modal.tsx
index 9c98e00f32..28d7b0aa0c 100644
--- a/apps/web/ui/modals/add-edit-token-modal.tsx
+++ b/apps/web/ui/modals/add-edit-token-modal.tsx
@@ -21,7 +21,6 @@ import {
} from "@dub/ui";
import { ToggleGroup } from "@dub/ui/src/toggle-group";
import { SimpleTooltipContent } from "@dub/ui/src/tooltip";
-import { cn } from "@dub/utils";
import {
Dispatch,
FormEvent,
@@ -189,38 +188,21 @@ function AddEditTokenModal({
/>
</Label>
</div>
- <div
- className={cn(
- "flex w-1/2 items-center space-x-2 rounded-md border border-gray-300 bg-white transition-all hover:bg-gray-50 active:bg-gray-100",
- {
- "cursor-not-allowed opacity-75": !isOwner,
- },
- )}
- >
+ <div className="flex w-1/2 items-center space-x-2 rounded-md border border-gray-300 bg-white transition-all hover:bg-gray-50 active:bg-gray-100">
<RadioGroupItem
value="machine"
id="machine"
className="ml-3"
- disabled={!isOwner}
/>
<Label
htmlFor="machine"
- className={cn(
- "flex flex-1 cursor-pointer items-center justify-between space-x-1 p-3 pl-0",
- {
- "cursor-not-allowed": !isOwner,
- },
- )}
+ className="flex flex-1 cursor-pointer items-center justify-between space-x-1 p-3 pl-0"
>
<p className="text-gray-600">Machine</p>
<InfoTooltip
content={
<SimpleTooltipContent
- title={
- isOwner
- ? "A new bot member will be added to your workspace, and the key will be associated with it. Since the key is not tied to your account, it will not be deleted even if you leave the workspace."
- : "Only the workspace owner can create machine users."
- }
+ title="A new bot member will be added to your workspace, and the key will be associated with it. Since the key is not tied to your account, it will not be deleted even if you leave the workspace."
cta="Learn more"
href="https://dub.co/docs/api-reference/tokens#machine-users"
/>