Skip to content

Commit

Permalink
Add verification to make sure the user exists in REST insert object h…
Browse files Browse the repository at this point in the history
…elper (#11008)

Add verification to make sure the user exists in REST  insert object helper
  • Loading branch information
MarcosSpessatto authored and rodrigok committed Jun 20, 2018
1 parent c53fa4d commit f33c6b5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/rocketchat-api/server/helpers/insertUserObject.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
RocketChat.API.helperMethods.set('insertUserObject', function _addUserToObject({ object, userId }) {
const { username, name } = RocketChat.models.Users.findOneById(userId);
const user = RocketChat.models.Users.findOneById(userId);
object.user = { };
if (user) {
object.user = {
_id: userId,
username: user.username,
name: user.name
};
}

object.user = {
_id: userId,
username,
name
};

return object;
});
Expand Down

0 comments on commit f33c6b5

Please sign in to comment.