Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Check if a result was retrieved
if (result) {
// Check if an error was retrieved
if (result.error) {
// Do not allow rendering when there was an error
this.setState({
allowRender: false
});
console.error(`Error retrieved while checking user's remote list or library permissions.`);
return;
}
// Check the result high and low value are returned
if (typeof result.High !== "undefined" && typeof result.Low !== "undefined") {
// Create the permission mask
const permission = new SPPermission(result);
const hasPermissions = permission.hasAllPermissions(...permissions);
this.setState({
allowRender: hasPermissions
});
return;
}
} else {
this.setState({
allowRender: false
});
console.error(`No result value was retrieved when checking the user's remote list or library permissions.`);
return;
}
}
}