I am getting subject error while registering a simple Mean Application through http://localhost:3000/auth/register, that I have simply created using mean init
command. pbkdf2
or crypto
is generating the error and I have no idea where to look for it.
I have done lots of different things like cleared npm cache, reinstalled using npm etc. Please help me out. Following is some more information.
Mean --version: 0.12.15
npm --version: 5.0.3
node --version: v8.1.0
bower --version: 1.8.0
gulp --version: CLI and Local: 3.9.1
Code for model.UserSchema.methods.hashPassword
(D:\Projects\Mean\CampaignBuilder\node_modules\meanio-users\server\models\user.js)
/**
* Hash password
*
* @param {String} password
* @return {String}
* @api public
*/
UserSchema.methods.hashPassword = function(password) {
if (!password || !this.salt) return '';
var salt = new Buffer(this.salt, 'base64');
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
};
Register page calls http://localhost:3000/api/register and it generates 500 Internal Server Error
.
Firefox is showing following response:
TypeError: The "digest" argument is required and must not be undefined
at pbkdf2 (crypto.js:635:11)
at Object.exports.pbkdf2Sync (crypto.js:628:10)
at model.UserSchema.methods.hashPassword (D:\Projects\Mean\CampaignBuilder\node_modules\meanio-users\server\models\user.js:165:17)
at model.<anonymous> (D:\Projects\Mean\CampaignBuilder\node_modules\meanio-users\server\models\user.js:94:31)
at VirtualType.applySetters (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\virtualtype.js:94:25)
at model.Document.set (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\document.js:656:12)
at model._handleIndex (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\document.js:587:14)
at model.Document.set (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\document.js:547:24)
at model.Document (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\document.js:71:12)
at model.Model (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\model.js:46:12)
at new model (D:\Projects\Mean\CampaignBuilder\node_modules\mongoose\lib\model.js:3621:13)
at create (D:\Projects\Mean\CampaignBuilder\node_modules\meanio-users\server\controllers\users.js:86:24)
at Layer.handle [as handle_request] (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\layer.js:95:5)
at next (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\layer.js:95:5)
at D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:281:22
at Function.process_params (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:335:12)
at next (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:275:10)
at loadUser (D:\Projects\Mean\CampaignBuilder\node_modules\meanio-users\server\controllers\users.js:202:24)
at Layer.handle [as handle_request] (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:317:13)
at D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:284:7
at Function.process_params (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:335:12)
at next (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:275:10)
at D:\Projects\Mean\CampaignBuilder\node_modules\connect-modrewrite\index.js:129:7
at Layer.handle [as handle_request] (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\layer.js:95:5)
at trim_prefix (D:\Projects\Mean\CampaignBuilder\node_modules\meanio\lib\core_modules\server\node_modules\express\lib\router\index.js:317:13)