Skip to content

Commit

Permalink
Fix REST /me regression (#10833)
Browse files Browse the repository at this point in the history
Fix: Regression in REST API endpoint `/me`
  • Loading branch information
MarcosSpessatto authored and rodrigok committed May 21, 2018
1 parent 4ed57e0 commit 202bb31
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/rocketchat-api/server/helpers/getUserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ const getInfoFromUserObject = (user) => {

RocketChat.API.helperMethods.set('getUserInfo', function _getUserInfo(user) {
const me = getInfoFromUserObject(user);
const verifiedEmail = me.emails.find((email) => email.verified);
const isVerifiedEmail = () => {
if (me && me.emails && Array.isArray(me.emails)) {
return me.emails.find((email) => email.verified);
}
return false;
};
const getUserPreferences = () => {
const defaultUserSettingPrefix = 'Accounts_Default_User_Preferences_';
const allDefaultUserSettings = RocketChat.settings.get(new RegExp(`^${ defaultUserSettingPrefix }.*$`));
Expand All @@ -41,7 +46,7 @@ RocketChat.API.helperMethods.set('getUserInfo', function _getUserInfo(user) {
return accumulator;
}, {});
};

const verifiedEmail = isVerifiedEmail();
me.email = verifiedEmail ? verifiedEmail.address : undefined;
me.settings = {
preferences: getUserPreferences()
Expand Down

0 comments on commit 202bb31

Please sign in to comment.