diff --git a/controllers/user.js b/controllers/user.js index 0740141de2..144c4124b8 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -145,7 +145,8 @@ exports.getAccount = function(req, res) { title: 'Manage your Free Code Camp Account', challenges: c, ch: req.user.challengesHash, - moment: moment + moment: moment, + user: req.user }); }); }; diff --git a/public/js/main.js b/public/js/main.js index dd14e952de..0760ba8176 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -43,9 +43,14 @@ $(document).ready(function() { }); var profileValidation = angular.module('profileValidation',[]); -profileValidation.controller('profileValidationController', ['$scope', - function($scope) { - $scope.twitterHandle = '@yournamehere'; - $scope.user.name = req.user.name; +profileValidation.controller('profileValidationController', ['$scope', '$http', + function($scope, $http) { + $http.get('/account').success(function(data) { + console.log('============'); + console.log(data); + console.log('============'); + $scope.user = data.user; + }); + //$scope.user = user; } ]); diff --git a/views/account/profile.jade b/views/account/profile.jade index 30056b1ab1..545ff53e5c 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -4,11 +4,11 @@ block content .container.text-center h1 Update your profile here: form.form-horizontal(action='/account/profile', method='POST') - //input(type='hidden', name='_csrf', value=_csrf) - //.form-group - // label.col-sm-3.col-sm-offset-2.control-label(for='name') Name - // .col-sm-4 - // input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') + input(type='hidden', name='_csrf', value=_csrf) + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='name') Name + .col-sm-4 + input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='name') Name .col-sm-4 @@ -28,9 +28,9 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle .col-sm-4 - input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model="twitterHandle" value='#{user.profile.twitterHandle}') + input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model="user.twitterHandle" value='#{user.profile.twitterHandle}') span - {{twitterHandle}} + {{user.twitterHandle}} .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link .col-sm-4