Skip to content

Commit 1896a2f

Browse files
author
schmidgallm
committed
add conditional to check if user is admin before making other admins
1 parent a7d26ca commit 1896a2f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

functions/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ admin.initializeApp();
66

77
// add admin role function
88
exports.addAdminRole = functions.https.onCall((data, context) => {
9+
// check request is made by admin
10+
if (context.auth.token.admin !== true) {
11+
return {
12+
error: 'Only admins can add other admins',
13+
};
14+
}
915
// get user and add custom claim (admin)
1016
return admin
1117
.auth()

0 commit comments

Comments
 (0)