Created
October 13, 2022 12:57
-
-
Save GregRos/b65d41d2696e4010d8345868ed7aa70a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Updates the squggle by id | |
export async function updateSquggle(data) { | |
const owner = await getSquggleOwnerInfo(data.id) | |
if (owner.id !== USER) { | |
if (!owner.isTeam) { | |
throw new Error("Owner not a team") | |
} | |
const perms = await getUserTeamPermissions(owner.id) | |
if (!perms) { | |
throw new Error("User not member of team") | |
} | |
if ("name" in data && perms !== "ADMIN") { | |
throw new Error("Not enough permissions") | |
} | |
if (perms !== "WRITE" && perms !== "ADMIN") { | |
throw new Error("Not enough permissions") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment