bump
Some checks failed
Build and Release / build-and-release (push) Has been cancelled

This commit is contained in:
Bryan1029384756
2026-04-20 17:09:04 -05:00
parent 82f8a12e27
commit b83360db35
48 changed files with 6079 additions and 49 deletions

View File

@@ -262,6 +262,24 @@ export const unassign = mutation({
},
});
/**
* Owner check — true for the bootstrap admin flag (isAdmin) AND for
* anyone bearing the reserved "Owner" role. Exposed as a query so
* the UI can gate destructive "whole-server" actions (Danger Zone)
* behind owner-only visibility without duplicating the rule.
*/
export const isOwner = query({
args: { userId: v.id("userProfiles") },
returns: v.boolean(),
handler: async (ctx, args) => {
const user = await ctx.db.get(args.userId);
if (!user) return false;
if (user.isAdmin) return true;
const roles = await getRolesForUser(ctx, args.userId);
return roles.some((r) => r.name === "Owner");
},
});
// Get current user's aggregated permissions
export const getMyPermissions = query({
args: { userId: v.id("userProfiles") },