Skip to content
Snippets Groups Projects
Commit e74b5e6a authored by Lucas Gabriel Lima's avatar Lucas Gabriel Lima
Browse files

add signup route to api

parent 9adc7e56
No related branches found
No related tags found
1 merge request!20Auth
Pipeline #
......@@ -12,6 +12,8 @@ const city = require('./city');
const school = require('./school');
const signup = require('./signup')
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' });
});
......@@ -22,5 +24,6 @@ api.use('/api/v1/state', state);
api.use('/api/v1/region', region);
api.use('/api/v1/city', city);
api.use('/api/v1/school', school);
api.use('/api/v1/signup', signup);
module.exports = api;
const express = require('express');
const signupApp = express();
const libs = `${process.cwd()}/libs`;
signupApp.post('/signup', function(req, res) {
if (!req.body.email || !req.body.password) {
res.json({success: false, msg: 'Please pass email and password.'});
} else {
var newUser = new User({
email: req.body.email,
password: req.body.password
});
// save the user
newUser.save(function(err) {
if (err) {
return res.json({success: false, msg: 'Email already in use.'});
}
res.json({success: true, msg: 'Successful created new user.'});
});
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment