mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
fix(types): permissions to string/bigint to prevent int scalability concerns
This commit is contained in:
parent
c55ce3b828
commit
6d1037f25e
8 changed files with 77 additions and 76 deletions
|
@ -2,6 +2,7 @@ import chroma from 'chroma-js';
|
|||
import * as React from 'react';
|
||||
import { FaCheck, FaTimes } from 'react-icons/fa';
|
||||
import { Role as RPCRole, RoleSafety } from 'roleypoly/common/types';
|
||||
import { evaluatePermission, permissions } from 'roleypoly/common/utils/hasPermission';
|
||||
import { numberToChroma } from 'roleypoly/design-system/atoms/colors';
|
||||
import * as styled from './Role.styled';
|
||||
|
||||
|
@ -67,12 +68,12 @@ const disabledReason = (role: RPCRole) => {
|
|||
case RoleSafety.HIGHERTHANBOT:
|
||||
return `This role is above Roleypoly's own role.`;
|
||||
case RoleSafety.DANGEROUSPERMISSIONS:
|
||||
const { permissions } = role;
|
||||
const rolePermissions = BigInt(role.permissions);
|
||||
let permissionHits: string[] = [];
|
||||
|
||||
(permissions & 0x00000008) === 0x00000008 &&
|
||||
evaluatePermission(rolePermissions, permissions.ADMINISTRATOR) &&
|
||||
permissionHits.push('Administrator');
|
||||
(permissions & 0x10000000) === 0x10000000 &&
|
||||
evaluatePermission(rolePermissions, permissions.MANAGE_ROLES) &&
|
||||
permissionHits.push('Manage Roles');
|
||||
|
||||
return `This role has unsafe permissions: ${permissionHits.join(', ')}`;
|
||||
|
|
|
@ -12,7 +12,7 @@ const adminRoles: Role[] = [
|
|||
{
|
||||
id: 'roley2',
|
||||
name: 'Admin',
|
||||
permissions: 0,
|
||||
permissions: '0',
|
||||
color: chroma('hotpink').num(),
|
||||
position: -1,
|
||||
managed: true,
|
||||
|
@ -21,7 +21,7 @@ const adminRoles: Role[] = [
|
|||
{
|
||||
id: 'roley3',
|
||||
name: 'Moderator',
|
||||
permissions: 0,
|
||||
permissions: '0',
|
||||
color: chroma('lime').num(),
|
||||
position: -1,
|
||||
managed: true,
|
||||
|
@ -32,7 +32,7 @@ const adminRoles: Role[] = [
|
|||
const roleypolyRole: Role = {
|
||||
id: 'roley',
|
||||
name: 'Roleypoly',
|
||||
permissions: 0,
|
||||
permissions: '0',
|
||||
color: chroma(palette.taupe500).num(),
|
||||
position: -1,
|
||||
managed: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue