@@ -43,6 +43,77 @@ const UserSchema = new mongoose.Schema({
4343 */
4444 token : { type : String } ,
4545
46+ /**
47+ * Array to store the history of token resets, including timestamps, reason,
48+ * executor, and old/new token values.
49+ * @type {Array<{
50+ * timestamp: Date,
51+ * reason: string,
52+ * isForced: boolean,
53+ * executor: string,
54+ * old_token: string,
55+ * new_token: string,
56+ * expiry?: Date
57+ * }>}
58+ */
59+ token_history : [
60+ {
61+ /**
62+ * Unique identifier for the token reset entry.
63+ * @type {string }
64+ * @required
65+ */
66+ _id : { type : String , required : true } ,
67+
68+ /**
69+ * Timestamp of the token reset.
70+ * @type {Date }
71+ * @default Date.now
72+ */
73+ timestamp : { type : Date , default : Date . now } ,
74+
75+ /**
76+ * Optional expiry time if token is meant to be invalidated after a period.
77+ * @type {Date }
78+ */
79+ expiry : { type : Date } ,
80+
81+ /**
82+ * Reason for the token reset (e.g., "suspicious activity", "user request").
83+ * @type {string }
84+ */
85+ reason : { type : String , default : 'Self Regenerated' } ,
86+
87+ /**
88+ * Indicates whether the token reset was forced (e.g., by an admin).
89+ * @type {boolean }
90+ * @default false
91+ */
92+ isForced : { type : Boolean , default : false } ,
93+
94+ /**
95+ * Information about the staff member or system who performed the reset.
96+ * @type {string }
97+ * @required
98+ */
99+ executor : { type : String , required : true , default : 'Self' } ,
100+
101+ /**
102+ * The token before the reset.
103+ * @type {string }
104+ * @required
105+ */
106+ old_token : { type : String , required : true } ,
107+
108+ /**
109+ * The token after the reset.
110+ * @type {string }
111+ * @required
112+ */
113+ new_token : { type : String , required : true } ,
114+ } ,
115+ ] ,
116+
46117 /**
47118 * Flag indicating whether the user is banned.
48119 * @type {boolean }
0 commit comments