summary refs log tree commit diff
path: root/util
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-05-31 17:30:21 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-05-31 17:30:21 +1000
commitbbcb7b684dd35fb01ed1e0c0cd9831b4284342d6 (patch)
tree4d69ebb19e2c188000035f9259a1436e118f9109 /util
parentMerge pull request #759 from MaddyUnderStars/fix/respectRegisterConfig (diff)
downloadserver-bbcb7b684dd35fb01ed1e0c0cd9831b4284342d6.tar.xz
Added a configurable default rights value
Diffstat (limited to 'util')
-rw-r--r--util/src/entities/Config.ts29
-rw-r--r--util/src/entities/User.ts2
2 files changed, 30 insertions, 1 deletions
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index 063a4d4d..f77991a9 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -4,6 +4,7 @@ import crypto from "crypto";
 import { Snowflake } from "../util/Snowflake";
 import { SessionsReplace } from "..";
 import { hostname } from "os";
+import { Rights } from "../util/Rights";
 
 @Entity("config")
 export class ConfigEntity extends BaseClassWithoutId {
@@ -120,6 +121,7 @@ export interface ConfigValue {
 			secret: string | null;
 		};
 		ipdataApiKey: string | null;
+		defaultRights: string;
 	};
 	login: {
 		requireCaptcha: boolean;
@@ -311,6 +313,33 @@ export const DefaultConfigOptions: ConfigValue = {
 			secret: null,
 		},
 		ipdataApiKey: "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9",
+		defaultRights: (
+			Rights.FLAGS.CREATE_CHANNELS +
+			Rights.FLAGS.CREATE_DMS +
+			Rights.FLAGS.CREATE_DM_GROUPS +
+			Rights.FLAGS.CREATE_GUILDS +
+			Rights.FLAGS.CREATE_INVITES +
+			Rights.FLAGS.CREATE_ROLES +
+			Rights.FLAGS.CREATE_TEMPLATES +
+			Rights.FLAGS.CREATE_WEBHOOKS +
+			Rights.FLAGS.JOIN_GUILDS +
+			Rights.FLAGS.PIN_MESSAGES +
+			Rights.FLAGS.SELF_ADD_REACTIONS +
+			Rights.FLAGS.SELF_DELETE_MESSAGES +
+			Rights.FLAGS.SELF_EDIT_MESSAGES +
+			Rights.FLAGS.SELF_EDIT_NAME +
+			Rights.FLAGS.SEND_MESSAGES +
+			Rights.FLAGS.USE_ACTIVITIES +
+			Rights.FLAGS.USE_VIDEO +
+			Rights.FLAGS.USE_VOICE +
+			Rights.FLAGS.INVITE_USERS +
+			Rights.FLAGS.SELF_DELETE_DISABLE +
+			Rights.FLAGS.DEBTABLE +
+			Rights.FLAGS.KICK_BAN_MEMBERS +
+			Rights.FLAGS.SELF_LEAVE_GROUPS +
+			Rights.FLAGS.SELF_ADD_DISCOVERABLE +
+			Rights.FLAGS.USE_ACHIEVEMENTS
+		).toString()
 	},
 	login: {
 		requireCaptcha: false,
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts
index 9b1c494e..49a7fbc6 100644
--- a/util/src/entities/User.ts
+++ b/util/src/entities/User.ts
@@ -268,7 +268,7 @@ export class User extends BaseClass {
 			disabled: false,
 			deleted: false,
 			email: email,
-			rights: "0", // TODO: grant rights correctly, as 0 actually stands for no rights at all
+			rights: Config.get().security.defaultRights,
 			nsfw_allowed: true, // TODO: depending on age
 			public_flags: "0",
 			flags: "0", // TODO: generate