Added a default token to the Session.ts model
This commit is contained in:
parent
379bbbcd9f
commit
08b7bd5373
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user