diff --git a/controllers/user.js b/controllers/user.js index c03ab14d96..6e5674a636 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -11,34 +11,7 @@ var User = require('../models/User'); exports.getLogin = function(req, res) { if (req.user) return res.redirect('/'); res.render('account/login', { - title: 'Login', - errors: req.flash('errors') - }); -}; - -/** - * GET /signup - * Signup page. - */ - -exports.getSignup = function(req, res) { - if (req.user) return res.redirect('/'); - res.render('account/signup', { - title: 'Create Account', - errors: req.flash('errors') - }); -}; - -/** - * GET /account - * Profile page. - */ - -exports.getAccount = function(req, res) { - res.render('account/profile', { - title: 'Account Management', - success: req.flash('success'), - error: req.flash('error') + title: 'Login' }); }; @@ -76,6 +49,18 @@ exports.postLogin = function(req, res, next) { })(req, res, next); }; +/** + * GET /signup + * Signup page. + */ + +exports.getSignup = function(req, res) { + if (req.user) return res.redirect('/'); + res.render('account/signup', { + title: 'Create Account' + }); +}; + /** * POST /signup * Create a new local account. @@ -116,11 +101,22 @@ exports.postSignup = function(req, res, next) { }); }; +/** + * GET /account + * Profile page. + */ + +exports.getAccount = function(req, res) { + res.render('account/profile', { + title: 'Account Management' + }); +}; /** * POST /account/profile * Update profile information. */ + exports.postUpdateProfile = function(req, res, next) { User.findById(req.user.id, function(err, user) { if (err) return next(err); @@ -133,7 +129,7 @@ exports.postUpdateProfile = function(req, res, next) { user.save(function(err) { if (err) return next(err); - req.flash('success', 'Profile information updated.'); + req.flash('success', { msg: 'Profile information updated.' }); res.redirect('/account'); }); }); @@ -147,12 +143,12 @@ exports.postUpdateProfile = function(req, res, next) { exports.postUpdatePassword = function(req, res, next) { if (!req.body.password) { - req.flash('error', 'Password cannot be blank.'); + req.flash('errors', { msg: 'Password cannot be blank.' }); return res.redirect('/account'); } if (req.body.password !== req.body.confirmPassword) { - req.flash('error', 'Passwords do not match.'); + req.flash('errors', { msg: 'Passwords do not match.' }); return res.redirect('/account'); } @@ -163,7 +159,7 @@ exports.postUpdatePassword = function(req, res, next) { user.save(function(err) { if (err) return next(err); - req.flash('success', 'Password has been changed.'); + req.flash('success', { msg: 'Password has been changed.' }); res.redirect('/account'); }); }); diff --git a/views/account/login.jade b/views/account/login.jade index b8a259a5b5..db1ebe02bd 100644 --- a/views/account/login.jade +++ b/views/account/login.jade @@ -1,11 +1,6 @@ extends ../layout block content - if errors.length - .alert.alert-danger.animated.fadeIn - for error in errors - div= error.msg - .col-sm-8.col-sm-offset-2 form(method='POST') legend Sign In diff --git a/views/account/profile.jade b/views/account/profile.jade index f0f972745b..1cd7ebbb7c 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -1,16 +1,6 @@ extends ../layout block content - if error.length - .alert.alert-danger.animated.fadeIn - button.close(data-dismiss='alert') × - = error - if success.length - .alert.alert-success.animated.fadeInUp - button.close(data-dismiss='alert') × - i.fa.fa-check - = success - .page-header h3 Profile Information diff --git a/views/account/signup.jade b/views/account/signup.jade index f91ea1104e..f88ebc483a 100644 --- a/views/account/signup.jade +++ b/views/account/signup.jade @@ -1,11 +1,6 @@ extends ../layout block content - if errors.length - .alert.alert-danger.animated.fadeIn - for error in errors - div= error.msg - form.form-horizontal(id='signup-form', method='POST') legend Signup .form-group