mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix(usernames): don't supply username in public fields if unverified
This commit is contained in:
@@ -109,6 +109,8 @@ api.getMember = {
|
||||
|
||||
if (!member) throw new NotFound(res.t('userWithIDNotFound', {userId: memberId}));
|
||||
|
||||
if (!member.flags.verifiedUsername) delete member.auth.local.username;
|
||||
|
||||
// manually call toJSON with minimize: true so empty paths aren't returned
|
||||
let memberToJSON = member.toJSON({minimize: true});
|
||||
User.addComputedStatsToJSONObj(memberToJSON.stats, member);
|
||||
|
||||
@@ -8,7 +8,8 @@ require('./methods');
|
||||
// A list of publicly accessible fields (not everything from preferences because there are also a lot of settings tha should remain private)
|
||||
export let publicFields = `preferences.size preferences.hair preferences.skin preferences.shirt
|
||||
preferences.chair preferences.costume preferences.sleep preferences.background preferences.tasks preferences.disableClasses profile stats
|
||||
achievements party backer contributor auth.timestamps items inbox.optOut loginIncentives flags.classSelected auth.local.username`;
|
||||
achievements party backer contributor auth.timestamps items inbox.optOut loginIncentives flags.classSelected
|
||||
flags.verifiedUsername auth.local.username`;
|
||||
|
||||
// The minimum amount of data needed when populating multiple users
|
||||
export let nameFields = 'profile.name';
|
||||
|
||||
@@ -219,6 +219,9 @@ schema.statics.transformJSONUser = function transformJSONUser (jsonUser, addComp
|
||||
// Add id property
|
||||
jsonUser.id = jsonUser._id;
|
||||
|
||||
// Remove username if not verified
|
||||
if (!jsonUser.flags.verifiedUsername) delete jsonUser.auth.local.username;
|
||||
|
||||
if (addComputedStats) this.addComputedStatsToJSONObj(jsonUser.stats, jsonUser);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user