Skip to content
Snippets Groups Projects
Commit 39ff8c06 authored by V S Tharunika's avatar V S Tharunika
Browse files

added token to register function

parent 2f047a37
No related branches found
No related tags found
No related merge requests found
......@@ -14,13 +14,16 @@ module.exports={
try{
const user= await User.create(req.body)
res.send(user.toJSON())
const userJson = user.toJSON()
res.send({
user: userJSON,
token: jwtSignUser(userJson)
})
} catch (err){
res.status(400).send({
error: 'This email account is already in use.'
})
}
},
async login(req, res) {
try{
......
const Promise = require('bluebird')
const bcrypt = Promise.promisifiyAll(require('bcrypt-nodejs'))
const bcrypt = Promise.promisifyAll(require('bcrypt-nodejs'))
function hashPassword (user, options) {
const SALT_FACTOR = 8
......@@ -17,7 +17,7 @@ function hashPassword (user, options) {
}
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('user',{
const User = sequelize.define('User', {
email: {
type: DataTypes.STRING,
unique: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment