Code refactoring

This commit is contained in:
Sahat Yalkabov
2013-12-20 00:50:44 -05:00
parent c6fddb33f5
commit a6d762b071
3 changed files with 12 additions and 10 deletions

View File

@ -23,6 +23,7 @@ exports.getAccount = function(req, res) {
exports.postAccountProfileTab = function(req, res, next) {
User.findById(req.user.id, function(err, user) {
if (err) return next(err);
user.profile.name = req.body.name || '';
user.profile.email = req.body.email || '';
user.profile.gender = req.body.gender || '';
@ -42,6 +43,7 @@ exports.postAccountProfileTab = function(req, res, next) {
*/
exports.postAccountSettingsTab = function(req, res) {
// TODO: Virtual mongodb
if (!req.body.password || !req.body.confirm.password) {
req.flash('error', 'Passwords cannot be blank');
return res.redirect('/account');
@ -125,7 +127,7 @@ exports.getSignup = function(req, res) {
/**
* POST /signup
*/
exports.postSignup = function(req, res) {
exports.postSignup = function(req, res, next) {
// TODO: add mongoose validation on ToS (virtual?)
// TODO: Mongoose virtual, move logic to model
@ -139,7 +141,6 @@ exports.postSignup = function(req, res) {
return res.redirect('/signup');
}
var user = new User({
username: req.body.username,
password: req.body.password