Encrypted the Session.ts

This commit is contained in:
Mathias Wagner 2023-01-15 00:31:29 +01:00
parent 6a9b3c2c5e
commit 61026cbe3c
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,4 +1,5 @@
import {model, ObjectId, Schema, Types} from "mongoose";
import encrypt from "mongoose-encryption";
interface ISession {
id: ObjectId,
@ -19,4 +20,9 @@ const SessionSchema = new Schema<ISession>({
userAgent: String
});
SessionSchema.plugin(encrypt, {
encryptionKey: process.env.ENC_KEY,
signingKey: process.env.SIG_KEY
});
export const Session = model<ISession>('sessions', SessionSchema);