答案 0 :(得分:2)
请转到Divi>包括>建设者> functions.php文件,你可以在那里找到代码。
const mongoose = require ("mongoose");
const Spec = require("./specialist");
const Person = require("./person");
const Company = require("./company");
const bcrypt = require("bcryptjs");
module.exports.findUser=function(username,callback){
let query = {email_num:username};
Spec.findOne(query,(err_spec,spec_user)=>{
if(err_spec) throw err_spec;
if(!spec_user){
Person.findOne(query,(err_person,person_user)=>{
if(err_person) throw err_person;
if(!person_user){
Company.findOne(query,(err_company,company_user)=>{
if(err_company) throw err_company;
if(!company_user){
return console.log("Error User Not Found");
}
return callback(null,company_user);
});
}
return callback(null,person_user);
});
}
return callback(null,spec_user);
});
};
module.exports.comparePassword = function(candidatePassword, hash, callback){
bcrypt.compare(candidatePassword, hash, (err, isMatch) => {
if(err) throw err;
callback(null, isMatch);
});
};
module.exports.saveToken = function(username,role,token,callback){
let query = {email_num:username};
let updateToken={updatedToken:token};
if(role==="Person-User"){
Person.findOneAndUpdate(query,updateToken,callback);
}else if(role==="Specialist-User"){
Spec.findOneAndUpdate(query,updateToken,callback);
}else if(role==="Company-User"){
Company.findOneAndUpdate(query,updateToken,callback);
}else{
console.log("Something went goes wrong");
}
}
删除和|从这里>保存并检查。