diff --git a/lib/boot/index.js b/lib/boot/index.js index 2721ebb3b8..9ffc6d0ef5 100644 --- a/lib/boot/index.js +++ b/lib/boot/index.js @@ -63,7 +63,7 @@ app.use('/facebook-card', require('lib/facebook-card')); * Local signin routes */ -app.use('/signin', require('lib/signin')); +app.use('/signin', require('lib/signin-api')); /* * Local signup routes @@ -167,4 +167,5 @@ app.use(require('lib/admin')); app.use(require('lib/settings')); app.use(require('lib/forgot')); app.use(require('lib/help')); +app.use(require('lib/signin')); app.use(require('lib/404')); diff --git a/lib/signin-api/index.js b/lib/signin-api/index.js new file mode 100644 index 0000000000..ff6caa98fc --- /dev/null +++ b/lib/signin-api/index.js @@ -0,0 +1,38 @@ +/** + * Module dependencies. + */ + +var express = require('express'); +var mongoose = require('mongoose'); +var t = require('t-component'); +var Citizen = mongoose.model('Citizen'); +var auth = Citizen.authenticate(); + +/** + * Exports Application + */ + +var app = module.exports = express(); + + +/** + * Define routes for SignUp module + */ + +app.post('/', function(req, res, next) { + auth(req.body.email, req.body.password, function (err, citizen, info) { + if (err) { + return res.json(200, { error: t(err.message) }); + }; + if (!citizen) { + return res.json(200, { error: t(info.message) }); + }; + if (!citizen.emailValidated) { + return res.json(200, { error: t("Email not validated") }); + }; + req.login(citizen, function(err) { + if (err) return res.json(200, { error: t(err.message) }); + return res.json(200); + }); + }) +}); \ No newline at end of file diff --git a/lib/signin/index.js b/lib/signin/index.js index ba2e54e4ec..0ce4bb1337 100644 --- a/lib/signin/index.js +++ b/lib/signin/index.js @@ -2,45 +2,7 @@ * Module dependencies. */ -var express = require('express') - , mongoose = require('mongoose') - , t = require('t-component') - , Citizen = mongoose.model('Citizen') - , auth = Citizen.authenticate() +var express = require('express'); +var app = module.exports = express(); - ; - -/** - * Lazy register SignUp Application - */ - -var app; - -/** - * Exports Application - */ - -module.exports = app = express(); - - -/** - * Define routes for SignUp module - */ - -app.post('/', function(req, res, next) { - auth(req.body.email, req.body.password, function (err, citizen, info) { - if (err) { - return res.json(200, { error: t(err.message) }); - }; - if (!citizen) { - return res.json(200, { error: t(info.message) }); - }; - if (!citizen.emailValidated) { - return res.json(200, { error: t("Email not validated") }); - }; - req.login(citizen, function(err) { - if (err) return res.json(200, { error: t(err.message) }); - return res.json(200); - }); - }) -}); \ No newline at end of file +app.get('/signin', require('lib/layout')); \ No newline at end of file