fix(api): resolve /me 500 and revoke not persisting (GRO-206) #161

Closed
groombook-engineer[bot] wants to merge 10 commits from fix/gro-206-superuser-revoke-bug into main
Showing only changes of commit 9724327559 - Show all commits
+2 -2
View File
@@ -120,7 +120,7 @@ staffRouter.patch("/:id", zValidator("json", updateStaffSchema), async (c) => {
.where(and(eq(staff.isSuperUser, true), eq(staff.active, true), ne(staff.id, targetId)))
.limit(2);
if (superUserCount.length <= 1) {
if (superUserCount.length < 1) {
return [
body.isSuperUser === false
? "Cannot revoke the last super user. Assign another super user first."
@@ -201,7 +201,7 @@ staffRouter.delete("/:id", async (c) => {
.from(staff)
.where(and(eq(staff.isSuperUser, true), eq(staff.active, true), ne(staff.id, id)))
.limit(2);
if (superUserCount.length <= 1) {
if (superUserCount.length < 1) {
return ["Cannot delete the last super user. Assign another super user first.", null];
}
}