Added a default token to the Session.ts model

This commit is contained in:
Mathias Wagner 2023-01-15 19:42:24 +01:00
parent 379bbbcd9f
commit 08b7bd5373
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -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<ISession>({
},
token: {
type: String,
required: true
default: () => crypto.randomBytes(48).toString('hex')
},
ip: String,
userAgent: String,