Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Apr 4, 2024
1 parent e120d41 commit 23192c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions front/lib/api/invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ export async function getPendingInvitations(
if (!owner) {
return [];
}
if (!auth.isAdmin()) {
throw new Error(
"Only users that are `admins` for the current workspace can see membership invitations or modify it."
);
}

const invitations = await MembershipInvitation.findAll({
where: {
Expand Down Expand Up @@ -194,6 +199,11 @@ export async function getRecentPendingOrRevokedInvitations(
if (!owner) {
return [];
}
if (!auth.isAdmin()) {
throw new Error(
"Only users that are `admins` for the current workspace can see membership invitations or modify it."
);
}
const oneDayAgo = new Date();
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
const invitations = await MembershipInvitation.findAll({
Expand Down
2 changes: 1 addition & 1 deletion front/pages/api/w/[wId]/invitations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async function handler(
auth
);
if (
unconsumedInvitations.length >
unconsumedInvitations.length >=
MAX_UNCONSUMED_INVITATIONS_PER_WORKSPACE_PER_DAY
) {
return apiError(req, res, {
Expand Down

0 comments on commit 23192c9

Please sign in to comment.