Published
on
August 15, 2019
| 1,680 views
| 7 followers
members are following updates on this item.
Email privacy is a setting that allows users and or admins set the option to hide their email address across their digital workplace. This includes hiding it in the api responses as well. In some cases this can cause some unwanted pain for developers who really need the email address to make use of it's uniqueness in the Igloo platform. We all know you can change the privacy settings in the UI but what if you have 1000+ users? You probably want a more programmatic solution right?
First you will need to get the id of the users you want to update privacy for. This can by done by inspecting the DOM or, keeping with the theme of automation, you can get a list of users by using our APIs . Once you get the ids for the users you can move on to the next step.
Igloo has 5 different options that can set for profile privacy settings. Unknown = 0, Public = 1, Members = 2, Contacts = 3, Nobody = 4, in our case we will be using number 2 so that only members of the site can see the email address for users.
Notice the email privacy setting for this user before running our code. It's set to have Nobody access it.
getObjectById = (id) => {
const endpoint = `https://my.domain/.api/api.svc/objects/{id}/view`;
axios.get().then((response) => {
const result = response.data.response;
console.log(result);
}).catch((err) => {
console.log(err);
});
};
If you go back to the users profile option the users profile should have been updated with the change to their email privacy.
By default users have their privacy set to nobody but admins hold the power to change the privacy settings should they need to. In cases where email address is required and you want to programmatically set the email to allow members to view it, you can use what you learned here to achieve that goal.