Added a default token to the Session.ts model

This commit is contained in:
2023-01-15 19:42:24 +01:00
parent 379bbbcd9f
commit 08b7bd5373

View File

@@ -1,6 +1,6 @@
import {model, ObjectId, Schema, Types} from "mongoose"; import {model, ObjectId, Schema, Types} from "mongoose";
import { fieldEncryption } from "mongoose-field-encryption"; import { fieldEncryption } from "mongoose-field-encryption";
import process from "process"; import crypto from "crypto";
interface ISession { interface ISession {
id: ObjectId, id: ObjectId,
@@ -18,7 +18,7 @@ const SessionSchema = new Schema<ISession>({
}, },
token: { token: {
type: String, type: String,
required: true default: () => crypto.randomBytes(48).toString('hex')
}, },
ip: String, ip: String,
userAgent: String, userAgent: String,