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

fix: remove hardcoded teamId and allow managers to create tokens #1403

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading