diff --git a/common/app/routes/Profile/components/CamperHOC.jsx b/common/app/routes/Profile/components/CamperHOC.jsx
index b9e784b0c3..e4b4023bac 100644
--- a/common/app/routes/Profile/components/CamperHOC.jsx
+++ b/common/app/routes/Profile/components/CamperHOC.jsx
@@ -54,11 +54,11 @@ function CamperHOC({
return (
diff --git a/common/app/routes/Settings/components/Privacy-Settings.jsx b/common/app/routes/Settings/components/Privacy-Settings.jsx
index 96b038c541..5ef1196470 100644
--- a/common/app/routes/Settings/components/Privacy-Settings.jsx
+++ b/common/app/routes/Settings/components/Privacy-Settings.jsx
@@ -27,6 +27,7 @@ const propTypes = {
isLocked: PropTypes.bool,
showAbout: PropTypes.bool,
showCerts: PropTypes.bool,
+ showDonation: PropTypes.bool,
showHeatMap: PropTypes.bool,
showLocation: PropTypes.bool,
showName: PropTypes.bool,
@@ -39,15 +40,16 @@ const propTypes = {
function PrivacySettings(props) {
const {
- isLocked,
- showAbout,
- showCerts,
- showHeatMap,
- showLocation,
- showName,
- showPoints,
- showPortfolio,
- showTimeLine,
+ isLocked = true,
+ showAbout = false,
+ showCerts = false,
+ showDonation = false,
+ showHeatMap = false,
+ showLocation = false,
+ showName = false,
+ showPoints = false,
+ showPortfolio = false,
+ showTimeLine = false,
updateMyProfileUI,
user
} = props;
@@ -63,7 +65,7 @@ function PrivacySettings(props) {
There is also a button to see what data we hold on your account
+
diff --git a/common/models/user.js b/common/models/user.js
index 073ddd92aa..30035bdd3e 100644
--- a/common/models/user.js
+++ b/common/models/user.js
@@ -841,26 +841,83 @@ module.exports = function(User) {
});
};
+ function prepUserForPublish(user, profileUI) {
+ const {
+ about,
+ calendar,
+ completedChallenges,
+ isDonating,
+ location,
+ name,
+ points,
+ portfolio,
+ streak,
+ username
+ } = user;
+ const {
+ isLocked = true,
+ showAbout = false,
+ showCerts = false,
+ showDonation = false,
+ showHeatMap = false,
+ showLocation = false,
+ showName = false,
+ showPoints = false,
+ showPortfolio = false,
+ showTimeLine = false
+ } = profileUI;
+
+ if (isLocked) {
+ return {
+ isLocked,
+ username
+ };
+ }
+ return {
+ ...user,
+ about: showAbout ? about : '',
+ calendar: showHeatMap ? calendar : {},
+ completedChallenges: showCerts && showTimeLine ? completedChallenges : [],
+ isDonating: showDonation ? isDonating : null,
+ location: showLocation ? location : '',
+ name: showName ? name : '',
+ points: showPoints ? points : null,
+ portfolio: showPortfolio ? portfolio : [],
+ streak: showHeatMap ? streak : {}
+ };
+ }
+
User.getPublicProfile = function getPublicProfile(username, cb) {
return User.findOne$({ where: { username }})
.flatMap(user => {
if (!user) {
return Observable.of({});
}
- const { completedChallenges, progressTimestamps, timezone } = user;
+ const {
+ completedChallenges,
+ progressTimestamps,
+ timezone,
+ profileUI
+ } = user;
+ const allUser = {
+ ..._.pick(user, publicUserProps),
+ isGithub: !!user.githubProfile,
+ isLinkedIn: !!user.linkedIn,
+ isTwitter: !!user.twitter,
+ isWebsite: !!user.website,
+ points: progressTimestamps.length,
+ completedChallenges,
+ ...getProgress(progressTimestamps, timezone),
+ ...normaliseUserFields(user)
+ };
+
+ const publicUser = prepUserForPublish(allUser, profileUI);
+
return Observable.of({
entities: {
user: {
[user.username]: {
- ..._.pick(user, publicUserProps),
- isGithub: !!user.githubProfile,
- isLinkedIn: !!user.linkedIn,
- isTwitter: !!user.twitter,
- isWebsite: !!user.website,
- points: progressTimestamps.length,
- completedChallenges,
- ...getProgress(progressTimestamps, timezone),
- ...normaliseUserFields(user)
+ ...publicUser
}
}
},