本文整理汇总了TypeScript中bcrypt-nodejs.compare函数的典型用法代码示例。如果您正苦于以下问题:TypeScript compare函数的具体用法?TypeScript compare怎么用?TypeScript compare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compare函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
PlatformSchema.methods.comparePassword = function(candidatePassword: string, callback: Function): void {
bcrypt
.compare(candidatePassword, this.password, (err, isMatch: boolean) => {
if (err) { return callback(err) }
callback(null, isMatch)
})
}
示例2: it
it('Testing hash compare', function(done) {
bcrypt.compare(thePassword, theHash, (err, res) => {
expect(err).to.equal(null);
expect(res).to.equal(true);
done();
});
});
示例3: resolve
return await new Promise<boolean>((resolve, reject) => {
bcrypt.compare(password, encrypted, (err: Error, result: boolean) => {
if (err) {
resolve(false);
}
resolve(result);
});
});
示例4: function
userSchema.methods.comparePassword = function(inputPassword, callback) {
bcrypt.compare(inputPassword, this.password, (err, result)=>{
if(err){
return callback(err);
}
callback(null, result);
});
};
示例5: Promise
return new Promise((resolve, reject) => {
bcrypt.compare(user.receivedPass, user.password, function (err, res) {
if (err || !res) reject();
else {
delete user['receivedPass'];
resolve(user)
}
});
})
示例6: resolve
return new Promise<boolean>((resolve, reject) => {
bcrypt.compare(password, hash, (err, res) => {
/* istanbul ignore if */
if (err) {
console.log('There was an error in password-hash-bcrypt');
console.log(err);
resolve(false);
}
resolve(res);
});
});
示例7: ComparePassword
ComparePassword(password: string, callback: (match: boolean) => void): void {
if (!password) {
throw new Error("password doesn't contain value");
}
bcript.compare(password, this.Password, (error: Error, result: boolean): void => {
if (error) {
Log.c("User", "ComparePassword", error);
throw error;
}
callback(result);
});
}
示例8: function
const comparePassword: comparePasswordFunction = function (candidatePassword, cb) {
bcrypt.compare(candidatePassword, this.password, (err: mongoose.Error, isMatch: boolean) => {
cb(err, isMatch);
});
};
示例9: function
userSchema.methods.comparePassword = function (candidatePassword: string, cb: (err: any, isMatch: any) => {}) {
bcrypt.compare(candidatePassword, this.password, (err: mongoose.Error, isMatch: boolean) => {
cb(err, isMatch);
});
};
示例10: resolve
var promise = new Promise<boolean>((resolve, reject) => {
bcrypt.compare(unhashed, hashedString, (err, isCorrect: boolean) => {
if (err) return reject("[COMPARE] " + err);
resolve(Promise.resolve(isCorrect));
});
});