Here is the error am getting Even i have tried in the many ways but till the same issue in am getting(node:21416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
import User from "../models/user";
export const createConnectAccount = async (req, res) => {
// 1. find user from db
const user = await User.findById(req.user._id).exec();
console.log("USER ===> ", user);
// if user dont have stripe_account yet, create now
// 3. create account link based on account id (for frontend to complete onboarding)
// 4. update payment schedule (optional. default is 2 days)
};
import mongoose from "mongoose";
import bcrypt from "bcrypt";
const { Schema } = mongoose;
const userSchema = new Schema(
{
name: {
type: String,
trim: true,
required: "Name is required",
},
email: {
type: String,
trim: true,
required: "Eail is required",
unique: true,
},
password: {
type: String,
required: true,
min: 6,
max: 64,
},
stripe_account_id: "",
stripe_seller: {},
stripeSession: {},
},
{ timestamps: true }
);
userSchema.pre("save", function (next) {
let user = this;
// hash password only if user is changing the password or registering for the first time
// make sure to use this otherwise each time user.save() is executed, password
if (user.isModified("password")) {
return bcrypt.hash(user.password, 12, function (err, hash) {
if (err) {
console.log("BCRYPT HASH ERR ", err);
return next(err);
}
user.password = hash;
return next();
});
} else {
return next();
}
});
userSchema.methods.comparePassword = function (password, next) {
bcrypt.compare(password, this.password, function (err, match) {
if (err) {
console.log("COMPARE PASSWORD ERR", err);
return next(err, false);
} // if no err, we get null
console.log("MATCH PASSWORD", match);
return next(null, match); // true
});
};
export default mongoose.model("User", userSchema);