User profile information is now successfully saved and retrieved back on account profile page
This commit is contained in:
6
app.js
6
app.js
@ -50,8 +50,10 @@ app.get('/logout', user.logout);
|
||||
app.get('/signup', user.getSignup);
|
||||
app.post('/signup', user.postSignup);
|
||||
|
||||
app.get('/account', passportConf.ensureAuthenticated, user.account);
|
||||
app.get('/admin', passportConf.ensureAuthenticated, passportConf.ensureAdmin(), user.getAdmin);
|
||||
app.get('/account', passportConf.ensureAuthenticated, user.getAccount);
|
||||
app.post('/account/profile', passportConf.ensureAuthenticated, user.postAccountProfile);
|
||||
app.post('/account/settings', passportConf.ensureAuthenticated, user.postAccountSettings);
|
||||
|
||||
app.get('/partials/:name', home.partials);
|
||||
|
||||
app.get('/api', api.apiBrowser);
|
||||
|
@ -5,7 +5,7 @@ var mongoose = require('mongoose'),
|
||||
// Import models
|
||||
var User = require('../models/User');
|
||||
|
||||
exports.account = function(req, res) {
|
||||
exports.getAccount = function(req, res) {
|
||||
res.render('account', {
|
||||
title: 'Account Management',
|
||||
user: req.user,
|
||||
@ -13,6 +13,24 @@ exports.account = function(req, res) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.postAccountProfile = function(req, res) {
|
||||
User.findById(req.user.id, function(err, user) {
|
||||
user.profile.name = req.body.name || '';
|
||||
user.profile.email = req.body.email || '';
|
||||
user.profile.location = req.body.location || '';
|
||||
user.profile.website = req.body.website || '';
|
||||
user.profile.picture = req.body.picture || '';
|
||||
|
||||
user.save(function(err) {
|
||||
res.redirect('/account');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.postAccountSettings = function(req, res) {
|
||||
console.log('okay!!');
|
||||
};
|
||||
|
||||
/**
|
||||
* GET /login
|
||||
*/
|
||||
|
@ -9,33 +9,25 @@ block content
|
||||
a(href='#settings', data-toggle='tab') Settings
|
||||
.tab-content
|
||||
#basic.tab-pane.fade.active.in
|
||||
form.form-horizontal(role='form', method='POST')
|
||||
form.form-horizontal(action='/account/profile', method='POST')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='name') Name
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='name', id='name')
|
||||
input.form-control(type='text', name='name', id='name', value='#{user.profile.name}')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='email') Email
|
||||
.col-sm-4
|
||||
input.form-control(type='email', name='email', id='email')
|
||||
input.form-control(type='email', name='email', id='email', value='#{user.profile.email}')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='location') Location
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='location', id='location')
|
||||
input.form-control(type='text', name='location', id='location', value='#{user.profile.location}')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='website') Website
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='website', id='website')
|
||||
input.form-control(type='text', name='website', id='website', value='#{user.profile.website}')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='twitter') Twitter
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='twitter', id='twitter')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='linkedin') LinkedIn URL
|
||||
.col-sm-4
|
||||
input.form-control(type='text', name='linkedin', id='linkedin')
|
||||
.form-group
|
||||
label.col-sm-2.control-label(for='profilePicture') Profile picture
|
||||
label.col-sm-2.control-label(for='profilePicture') Profile Picture
|
||||
.col-sm-8
|
||||
.btn.btn-danger.google Use Google
|
||||
.btn.btn-primary.facebook Use Facebook
|
||||
|
Reference in New Issue
Block a user