Created
October 19, 2015 16:43
-
-
Save chanakaDe/8eba3dde1e9ebc51a6d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Create new user and save in database. | |
*/ | |
api.post('/signup', function (req, res) { | |
var user = new User({ | |
name: req.body.name, | |
username: req.body.username, | |
password: req.body.password | |
}); | |
var toekn = createToken(user); | |
user.save(function (err) { | |
if (err) { | |
res.send(err); | |
return; | |
} | |
res.json({ | |
success: true, | |
message: "User has been created", | |
token: toekn | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment