mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
More rights stuff
This commit is contained in:
parent
d0fea6be4b
commit
f33f9c6964
@ -1,6 +1,7 @@
|
||||
import { BitField } from "./BitField";
|
||||
import "missing-native-js-functions";
|
||||
import { BitFieldResolvable, BitFlag } from "./BitField";
|
||||
import { User } from "../entities";
|
||||
|
||||
var HTTPError: any;
|
||||
|
||||
@ -85,6 +86,16 @@ export class Rights extends BitField {
|
||||
// @ts-ignore
|
||||
throw new HTTPError(`You are missing the following rights ${permission}`, 403);
|
||||
}
|
||||
|
||||
export async function getRight(
|
||||
user_id: string,
|
||||
/** opts: {
|
||||
in_behalf?: (keyof User)[];
|
||||
} = {} **/)
|
||||
{
|
||||
user = await User.findOneOrFail({ where: { id: user_id } });
|
||||
return new Rights(user.right);
|
||||
}
|
||||
}
|
||||
|
||||
const ALL_RIGHTS = Object.values(Rights.FLAGS).reduce((total, val) => total | val, BigInt(0));
|
||||
|
Loading…
Reference in New Issue
Block a user