From 08b7bd5373067a838d4c2454a39d6acd5f77a030 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 15 Jan 2023 19:42:24 +0100 Subject: [PATCH] Added a default token to the Session.ts model --- src/models/Session.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/models/Session.ts b/src/models/Session.ts index 2607138..cf2119a 100644 --- a/src/models/Session.ts +++ b/src/models/Session.ts @@ -1,6 +1,6 @@ import {model, ObjectId, Schema, Types} from "mongoose"; import { fieldEncryption } from "mongoose-field-encryption"; -import process from "process"; +import crypto from "crypto"; interface ISession { id: ObjectId, @@ -18,7 +18,7 @@ const SessionSchema = new Schema({ }, token: { type: String, - required: true + default: () => crypto.randomBytes(48).toString('hex') }, ip: String, userAgent: String,