Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata was not passed through sanitizeUser function #1391

Merged
merged 2 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ way to update this template, but currently, we follow a pattern:

## Upcoming version 2020-XX-XX

- [fix] Pass metadata through sanitizeUser function.
[#1391](https://github.com/sharetribe/ftw-daily/pull/1391)
- [fix] Call for the same page caused unnecessary rendering
[#1388](https://github.com/sharetribe/ftw-daily/pull/1388)
- [fix] Fix Google Maps default centering if no bounds or center is given.
Expand Down
8 changes: 7 additions & 1 deletion src/util/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ const sanitizeText = str =>
export const sanitizeUser = entity => {
const { attributes, ...restEntity } = entity || {};
const { profile, ...restAttributes } = attributes || {};
const { bio, displayName, abbreviatedName, publicData } = profile || {};
const { bio, displayName, abbreviatedName, publicData, metadata } = profile || {};

const sanitizePublicData = publicData => {
// TODO: If you add public data, you should probably sanitize it here.
return publicData ? { publicData } : {};
};
const sanitizeMetadata = metadata => {
// TODO: If you add user-generated metadata through Integration API,
// you should probably sanitize it here.
return metadata ? { metadata } : {};
};

const profileMaybe = profile
? {
Expand All @@ -48,6 +53,7 @@ export const sanitizeUser = entity => {
displayName: sanitizeText(displayName),
bio: sanitizeText(bio),
...sanitizePublicData(publicData),
...sanitizeMetadata(metadata),
},
}
: {};
Expand Down