Skip to content

Commit

Permalink
Finalise profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
simonholmes committed Aug 19, 2015
1 parent 4c9fe31 commit 395fd48
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 12 deletions.
5 changes: 0 additions & 5 deletions app_api/config/passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ passport.use(new LocalStrategy({
usernameField: 'email'
},
function(username, password, done) {
console.log("Finding user: " + username + ";" + password);
User.findOne({ email: username }, function (err, user) {
console.log("user found");
console.log(user);
console.log("err found");
console.log(err);
if (err) { return done(err); }
// Return if user not found in database
if (!user) {
Expand Down
2 changes: 1 addition & 1 deletion app_api/controllers/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports.profileRead = function(req, res) {
});
} else {
User
.findById(req.params.userid)
.findById(req.payload._id)
.exec(function(err, user) {
res.status(200).json(user);
});
Expand Down
2 changes: 1 addition & 1 deletion app_api/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var ctrlProfile = require('../controllers/profile');
var ctrlAuth = require('../controllers/authentication');

// profile
router.get('/profile/:userid', auth, ctrlProfile.profileRead);
router.get('/profile', auth, ctrlProfile.profileRead);

// authentication
router.post('/register', ctrlAuth.register);
Expand Down
2 changes: 1 addition & 1 deletion app_client/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app_client/app.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app_client/auth/register/register.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
var vm = this;

vm.credentials = {
name : "Simon",
name : "",
email : "",
password : ""
};
Expand Down
23 changes: 23 additions & 0 deletions app_client/common/services/data.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {

angular
.module('meanApp')
.service('meanData', meanData);

meanData.$inject = ['$http', 'authentication'];
function meanData ($http, authentication) {

var getProfile = function () {
return $http.get('/api/profile', {
headers: {
Authorization: 'Bearer '+ authentication.getToken()
}
});
};

return {
getProfile : getProfile
};
}

})();
Loading

0 comments on commit 395fd48

Please sign in to comment.