Last active
October 13, 2022 13:29
-
-
Save GregRos/b75e35e046f7f70d50dc4f88dd7afc2b 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 to update name.") | |
} | |
if (perms !== "WRITE" && perms !== "ADMIN") { | |
throw new Error("Not enough permissions to update squggle.") | |
} | |
} | |
// ... UPDATE CODE ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment