1down votefavorite 
<http://stackoverflow.com/questions/43955670/cannot-register-user-with-bcrypt-postgresql#>

I am using nodejs + postgreSQL to do the registration of my app, so i have 
this basic model:

"use strict";var sequelize = require('./index');var bcrypt = 
require('bcryptjs');
module.exports = function (sequelize, DataTypes) {
  var User = sequelize.define("User", {
    username: DataTypes.STRING,
    email: DataTypes.STRING,
    password: DataTypes.STRING
  }, {
    instanceMethods: {
        generateHash: function(password) {
            return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
        },
        validPassword: function(password) {
            return bcrypt.compareSync(password, this.password);
        },
    }});

  return User;};

it worked before when i didn't had the password, now i want to hash that 
password and salt, so in my register route i have this:

    var express = require('express');var User = 
require('../../models').User;var router = express.Router();
/* GET users listing. */
router.post('/', function (req, res, next) {

  if (JSON.stringify(req.body) == "{}") {
    return res.status(400).json({ Error: "Register request body is empty" });
  }
  if (!req.body.email || !req.body.username || !req.body.password) {
    return res.status(400).json({ Error: "Missing fields for registration" });
  }

  var password = User.generateHash(req.body.password);

  User.create({
    username: req.body.username,
    email: req.body.email,
    password: password
  }).then(function () {
    return res.status(200).json({message: "user created"});
  })
});
module.exports = router;

now i just don't get any response of my postman and the row isn't saving on 
the databse any sugestion?

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/b6a7a175-3c86-4b2f-a785-32862bb065d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to