Skip to content

Commit

Permalink
Merge pull request #1403 from mfts/chore-remove-hardcoded-teamId
Browse files Browse the repository at this point in the history
fix: remove hardcoded teamId and allow managers to create tokens
  • Loading branch information
mfts authored Nov 26, 2024
2 parents de94bd1 + e221114 commit a456db4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 0 additions & 9 deletions pages/api/links/download/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ export default async function handle(
data: { downloadedAt: new Date() },
});

// TODO: team hardcode for special download
if (
view.document!.teamId === "clwt1qwt00000qz39aqra71w6" &&
view.document!.versions[0].type === "sheet"
) {
const downloadUrl = view.document!.versions[0].file;
return res.status(200).json({ downloadUrl });
}

const downloadUrl = await getFile({
type: view.document!.versions[0].storageType,
data:
Expand Down
14 changes: 10 additions & 4 deletions pages/api/teams/[teamId]/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ export default async function handle(
},
});

// Only admins can create tokens
if (role !== "ADMIN") {
return res.status(403).json({ error: "Forbidden" });
// Only admins and managers can create tokens
if (role !== "ADMIN" && role !== "MANAGER") {
return res.status(403).json({
error:
"You don't have the permissions to create a token. Please contact your administrator or manager.",
});
}

// Generate token
Expand Down Expand Up @@ -151,7 +154,10 @@ export default async function handle(

// Only admins can delete tokens
if (role !== "ADMIN") {
return res.status(403).json({ error: "Forbidden" });
return res.status(403).json({
error:
"You don't have the permissions to delete a token. Please contact your administrator.",
});
}

// Delete the token
Expand Down

0 comments on commit a456db4

Please sign in to comment.