fix(about): Return empty object for no user (#17714)

This commit is contained in:
Stuart Taylor
2018-06-25 20:20:40 +01:00
committed by mrugesh mohapatra
parent 65cb3886ff
commit c459572fcf

View File

@ -493,9 +493,7 @@ module.exports = function(User) {
if (!username) {
// Zalgo!!
return nextTick(() => {
cb(new TypeError(
`username should be a string but got ${ username }`
));
cb(null, {});
});
}
return User.findOne({ where: { username } }, (err, user) => {
@ -503,7 +501,7 @@ module.exports = function(User) {
return cb(err);
}
if (!user || user.username !== username) {
return cb(new Error(`no user found for ${ username }`));
return cb(null, {});
}
const aboutUser = getAboutProfile(user);
return cb(null, aboutUser);