Skip to content

Commit

Permalink
More robust check if a User document shows it's a global.admin
Browse files Browse the repository at this point in the history
  • Loading branch information
am-MongoDB authored Jul 28, 2020
1 parent be51d66 commit 30e33a3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion WildAidDemo/functions/isGlobalAdmin/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ exports = function(emailAddress){
return userCollection.findOne({email: emailAddress})
.then ( userDoc => {
console.log(`${emailAddress} is a global admin? - ${userDoc.global && userDoc.global.admin}`);
return (userDoc.global && userDoc.global.admin);
if (userDoc.global) {
if (userDoc.global.admin) {
return true;
} else {
return false;
}
} else {
console.log("Missing global attribute from User document");
return false;
}
}).catch( e => { console.log(e); return false; });
};

0 comments on commit 30e33a3

Please sign in to comment.