Refactoring
This commit is contained in:
4
app.js
4
app.js
@ -95,8 +95,8 @@ if (cluster.isMaster) {
|
|||||||
app.get('/contact', contactController.getContact);
|
app.get('/contact', contactController.getContact);
|
||||||
app.post('/contact', contactController.postContact);
|
app.post('/contact', contactController.postContact);
|
||||||
app.get('/account', passportConf.isAuthenticated, userController.getAccount);
|
app.get('/account', passportConf.isAuthenticated, userController.getAccount);
|
||||||
app.post('/account/profile', passportConf.isAuthenticated, userController.postAccountProfileTab);
|
app.post('/account/profile', passportConf.isAuthenticated, userController.postUpdateProfile);
|
||||||
app.post('/account/settings', passportConf.isAuthenticated, userController.postAccountSettingsTab);
|
app.post('/account/password', passportConf.isAuthenticated, userController.postUpdatePassword);
|
||||||
app.post('/account/delete', passportConf.isAuthenticated, userController.postDeleteAccount);
|
app.post('/account/delete', passportConf.isAuthenticated, userController.postDeleteAccount);
|
||||||
app.get('/account/unlink/:provider', passportConf.isAuthenticated, userController.getOauthUnlink);
|
app.get('/account/unlink/:provider', passportConf.isAuthenticated, userController.getOauthUnlink);
|
||||||
app.get('/api', apiController.getApi);
|
app.get('/api', apiController.getApi);
|
||||||
|
@ -7,7 +7,7 @@ var User = require('../models/User');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /account
|
* GET /account
|
||||||
* User account page
|
* User account page.
|
||||||
*/
|
*/
|
||||||
exports.getAccount = function(req, res) {
|
exports.getAccount = function(req, res) {
|
||||||
res.render('account/profile', {
|
res.render('account/profile', {
|
||||||
@ -18,10 +18,10 @@ exports.getAccount = function(req, res) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account#profile
|
* POST /account/profile
|
||||||
* Update user's profile information
|
* Update profile information.
|
||||||
*/
|
*/
|
||||||
exports.postAccountProfileTab = function(req, res, next) {
|
exports.postUpdateProfile = function(req, res, next) {
|
||||||
User.findById(req.user.id, function(err, user) {
|
User.findById(req.user.id, function(err, user) {
|
||||||
if (err) return next(err);
|
if (err) return next(err);
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ exports.postAccountProfileTab = function(req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account#settings
|
* POST /account/password
|
||||||
* Update user's current password
|
* Update current password.
|
||||||
*/
|
*/
|
||||||
exports.postAccountSettingsTab = function(req, res, next) {
|
exports.postUpdatePassword = function(req, res, next) {
|
||||||
|
|
||||||
// TODO: Use Virtuals (mongoose)
|
// TODO: Use Virtuals (mongoose)
|
||||||
if (!req.body.password || !req.body.confirm.password) {
|
if (!req.body.password || !req.body.confirm.password) {
|
||||||
@ -69,7 +69,7 @@ exports.postAccountSettingsTab = function(req, res, next) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /account/delete
|
* POST /account/delete
|
||||||
* Delete user's account
|
* Delete user account.
|
||||||
*/
|
*/
|
||||||
exports.postDeleteAccount = function(req, res, next) {
|
exports.postDeleteAccount = function(req, res, next) {
|
||||||
User.remove({ _id: req.user.id }, function(err) {
|
User.remove({ _id: req.user.id }, function(err) {
|
||||||
|
Reference in New Issue
Block a user