summary refs log tree commit diff
path: root/src/util/entities
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-09-20 16:43:35 +0200
committerGitHub <noreply@github.com>2022-09-20 16:43:35 +0200
commit313959557df08b03ae07a85c6faafa9817a9f696 (patch)
tree8e3c1e5159f0b1ee0eba3c9f69a15d7894430726 /src/util/entities
parentMerge pull request #885 from fosscord/dev/Maddy/fix/genSchemas (diff)
parentCourtesy: run prettier (diff)
downloadserver-313959557df08b03ae07a85c6faafa9817a9f696.tar.xz
Merge pull request #891 from fosscord/dev/improve-security
Improved security: one-time registration token support, register and message ratelimit
Diffstat (limited to 'src/util/entities')
-rw-r--r--src/util/entities/Attachment.ts2
-rw-r--r--src/util/entities/Invite.ts2
-rw-r--r--src/util/entities/ValidRegistrationTokens.ts12
-rw-r--r--src/util/entities/index.ts1
4 files changed, 15 insertions, 2 deletions
diff --git a/src/util/entities/Attachment.ts b/src/util/entities/Attachment.ts
index 8392f415..c0ea3dec 100644
--- a/src/util/entities/Attachment.ts
+++ b/src/util/entities/Attachment.ts
@@ -1,6 +1,6 @@
 import { BeforeRemove, Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
 import { URL } from "url";
-import { deleteFile } from "../util/cdn";
+import { deleteFile } from "../util/CDN";
 import { BaseClass } from "./BaseClass";
 
 @Entity("attachments")
diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts
index f6ba85d7..151fcc59 100644
--- a/src/util/entities/Invite.ts
+++ b/src/util/entities/Invite.ts
@@ -1,4 +1,4 @@
-import { random } from "@fosscord/api";
+import { random } from "@fosscord/util";
 import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn, RelationId } from "typeorm";
 import { BaseClassWithoutId } from "./BaseClass";
 import { Channel } from "./Channel";
diff --git a/src/util/entities/ValidRegistrationTokens.ts b/src/util/entities/ValidRegistrationTokens.ts
new file mode 100644
index 00000000..5d0747b8
--- /dev/null
+++ b/src/util/entities/ValidRegistrationTokens.ts
@@ -0,0 +1,12 @@
+import { BaseEntity, Column, Entity, PrimaryColumn } from "typeorm";
+import { Config } from "..";
+
+@Entity("valid_registration_tokens")
+export class ValidRegistrationToken extends BaseEntity {
+	@PrimaryColumn()
+	token: string;
+	@Column()
+	created_at: Date = new Date();
+	@Column()
+	expires_at: Date = new Date(Date.now() + Config.get().security.defaultRegistrationTokenExpiration);
+}
diff --git a/src/util/entities/index.ts b/src/util/entities/index.ts
index 2b91c2ba..5342d951 100644
--- a/src/util/entities/index.ts
+++ b/src/util/entities/index.ts
@@ -29,5 +29,6 @@ export * from "./TeamMember";
 export * from "./Template";
 export * from "./User";
 export * from "./UserSettings";
+export * from "./ValidRegistrationTokens";
 export * from "./VoiceState";
 export * from "./Webhook";