本帖最後由 superwebguys 於 2022-1-28 15:44 編輯
回覆 2# gamezz
網上有些example 把 password validation 放在user model 內:- UsersSchema.methods.validatePassword = function(password) {
- const hash = crypto.pbkdf2Sync(password, this.salt, 10000, 512, 'sha512').toString('hex');
- return this.hash === hash;
- };
複製代碼 |