Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make gme edit permissions tied to user ids again
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 3ab93c7 commit 32387f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions app/routes/mod-queue.tsx
Expand Up @@ -82,6 +82,11 @@ export async function loader({ context }: { context: RequestContext }) {
});

return {
can_edit_ban_users: [
"165594923586945025",
"289372404541554689",
"396347223736057866",
].includes(currentUser.id),
departments: Object.entries(departments)
.filter((d) => d[1] & currentUser.permissions)
.map((arr) => arr[0]),
Expand Down
4 changes: 2 additions & 2 deletions functions/api/auth/session.ts
Expand Up @@ -120,10 +120,10 @@ export async function onRequestGet(context: RequestContext) {
const memberData: { [k: string]: any } = await serverMemberReq.json();

if (serverMemberReq.ok) {
userData.permissions = GetPermissions(userData.id, memberData.roles);
userData.permissions = await GetPermissions(userData.id, memberData.roles);
userData.roles = memberData.roles;
} else {
userData.permissions = GetPermissions(userData.id);
userData.permissions = await GetPermissions(userData.id);
}

const selectedTokenStart =
Expand Down
13 changes: 4 additions & 9 deletions functions/permissions.ts
@@ -1,4 +1,4 @@
export default function (userid: string, roles?: string[]): number {
export default async function (userid: string, roles?: string[], context?: RequestContext): Promise<number> {
let permissions = 0;

if (roles?.includes("374851061233614849")) permissions |= 1 << 0; // Administration
Expand All @@ -7,14 +7,9 @@ export default function (userid: string, roles?: string[]): number {
if (roles?.includes("391986108763996160")) permissions |= 1 << 3; // Events Team
if (roles?.includes("607697704419852289")) permissions |= 1 << 4; // Events Team Management
if (
[
"165594923586945025",
"289372404541554689",
"320758924850757633",
"396347223736057866",
"704247919259156521",
"891710683371167795",
].includes(userid)
["165594923586945025", "289372404541554689", "396347223736057866"].includes(
userid
) || (Boolean(await context?.env.DATA.get(`gamemod_${userid}`)))
)
permissions |= 1 << 5;
if (
Expand Down

0 comments on commit 32387f9

Please sign in to comment.