fix: change generateToken method to a static method on userSchema

This commit is contained in:
Danny Avila 2025-05-29 14:45:40 -04:00
parent 85d0688f38
commit 0cb5ed4063
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -309,7 +309,7 @@ userSchema.statics.deleteUserById = async function (userId: string) {
* @param {MongoUser} user - The user for whom the token is being generated.
* @returns {Promise<string>} A promise that resolves to a JWT token.
*/
userSchema.methods.generateToken = async function (user: IUser): Promise<string> {
userSchema.statics.generateToken = async function (user: IUser): Promise<string> {
if (!user) {
throw new Error('No user provided');
}