Last active
October 19, 2016 04:26
-
-
Save wsfuller/8c38bba0c3a556bc534a0d7e6ecfcebe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
var jwt = require('jsonwebtoken'); | |
var bcrypt = require('bcryptjs'); | |
var hash = 'superSecret'; | |
var config = require('../config/database'); | |
User = require('../models/user.model.js'); | |
// Create new User | |
router.post('/', function(req, res){ | |
var email = req.body.email; | |
var password = req.body.password; | |
var user = new User({ | |
email: email, | |
password: password | |
}); | |
// Pre hook will take care of password creation | |
return user.save() | |
.then(function(user) { | |
// return user successful and token | |
console.log('get ready to prepare the token'); | |
}); | |
}); |
Ok so passing a user object now back into the Model
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to make an instance of a user you cannot call the save method on the model