mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 01:15:47 +01:00
style changes
This commit is contained in:
@@ -1,37 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
(function (module) {
|
||||
var fork = require('child_process').fork;
|
||||
var path = require('path');
|
||||
|
||||
module.hash = function (rounds, password, callback) {
|
||||
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
|
||||
};
|
||||
var fork = require('child_process').fork;
|
||||
var path = require('path');
|
||||
|
||||
module.compare = function (password, hash, callback) {
|
||||
if (!hash || !password) {
|
||||
return setImmediate(callback, null, false);
|
||||
}
|
||||
forkChild({ type: 'compare', password: password, hash: hash }, callback);
|
||||
};
|
||||
exports.hash = function (rounds, password, callback) {
|
||||
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
|
||||
};
|
||||
|
||||
function forkChild(message, callback) {
|
||||
var forkProcessParams = {};
|
||||
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
|
||||
forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] };
|
||||
}
|
||||
var child = fork(path.join(__dirname, 'bcrypt'), [], forkProcessParams);
|
||||
|
||||
child.on('message', function (msg) {
|
||||
if (msg.err) {
|
||||
return callback(new Error(msg.err));
|
||||
}
|
||||
|
||||
callback(null, msg.result);
|
||||
});
|
||||
|
||||
child.send(message);
|
||||
exports.compare = function (password, hash, callback) {
|
||||
if (!hash || !password) {
|
||||
return setImmediate(callback, null, false);
|
||||
}
|
||||
forkChild({ type: 'compare', password: password, hash: hash }, callback);
|
||||
};
|
||||
|
||||
return module;
|
||||
}(exports));
|
||||
function forkChild(message, callback) {
|
||||
var forkProcessParams = {};
|
||||
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
|
||||
forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] };
|
||||
}
|
||||
var child = fork(path.join(__dirname, 'bcrypt'), [], forkProcessParams);
|
||||
|
||||
child.on('message', function (msg) {
|
||||
if (msg.err) {
|
||||
return callback(new Error(msg.err));
|
||||
}
|
||||
|
||||
callback(null, msg.result);
|
||||
});
|
||||
|
||||
child.send(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user