Created
January 7, 2018 23:38
-
-
Save danthegoodman1/f782cf41bc73ba7ab00c7a3182cd3682 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
const express = require('express'); | |
const router = express.Router(); | |
const User = require('../models/user.js'); | |
const passport = require('passport'); | |
const jwt = require('jsonwebtoken'); | |
// Register | |
router.post('/register', function(req, res, next){ | |
let newUser = new User({ | |
name: req.body.name, | |
email: req.body.email, | |
username: req.body.username, | |
password: req.body.password | |
}); | |
User.addUser(newUser, function(err, user){ | |
if(err){ | |
res.json({success: false, msg: "Failed to register User"}); | |
} else { | |
res.json({success: true, msg: "User registered"}); | |
} | |
}); | |
}); | |
// Authenticate | |
router.get('/auth', function(req, res, next){ | |
res.send('AUTH'); | |
}); | |
// profile | |
router.get('/profile', function(req, res, next){ | |
res.send('PROFILE'); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment