Created
October 13, 2022 13:08
-
-
Save GregRos/855af9822c2869abb9d92903e3c2d85b to your computer and use it in GitHub Desktop.
This file contains hidden or 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") | |
} | |
} | |
// ... UPDATE CODE ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment