Skip to content

Commit

Permalink
Fix issue with profiles for non-editors.
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed May 4, 2015
1 parent 3fee5bb commit 1ca84eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 6 additions & 2 deletions controllers/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ module.exports = {
});
},
edit: function(req, res, next) {
Person.findOne({ slug: req.param('usernameSlug') }).exec(function(err, person) {
if (!person) { return next(); }
if (!req.user) return next();
Person.findOne({
_id: req.user._id,
slug: req.param('usernameSlug')
}).exec(function(err, person) {
if (!person) return next();

person.bio = (req.param('bio')) ? req.param('bio') : person.bio;
person.email = (req.param('email')) ? req.param('email') : person.email;
Expand Down
3 changes: 1 addition & 2 deletions soundtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ app.get('/listening', requireLogin , function(req, res) {
//But first we record the token's authData, user and time.
//We use the recorded time to make sure we issued the token recently
app.post('/socket-auth', requireLogin, auth.configureToken);

app.post('/:usernameSlug', people.edit);
app.post('/chat', requireLogin, function(req, res) {
var room = app.rooms[ req.room ];
if (!room) return next();
Expand Down Expand Up @@ -863,7 +863,6 @@ app.get('/:usernameSlug/:playlistSlug', playlists.view);
app.get('/:usernameSlug/plays', people.listPlays);
app.get('/:usernameSlug/mentions', people.mentions);
app.get('/:usernameSlug', redirectToMainSite , people.profile);
app.post('/:usernameSlug', people.edit);

// catch-all route (404)
app.get('*', function(req, res) {
Expand Down

0 comments on commit 1ca84eb

Please sign in to comment.