-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create function and route to modify user claims
- Loading branch information
Showing
7 changed files
with
1,548 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
{ | ||
"editor.tabSize": 2, | ||
"editor.rulers": [ | ||
80 | ||
], | ||
"editor.rulers": [80], | ||
"editor.formatOnSave": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
serviceAccountKey.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
// Controllers here, following the pattern in ../customers/controllers.ts | ||
import * as admin from 'firebase-admin' | ||
|
||
const serviceAccount = require('../../serviceAccountKey.json') | ||
|
||
admin.initializeApp({ | ||
credential: admin.credential.cert(serviceAccount) | ||
}) | ||
|
||
/** | ||
* Modify the claim of a user given user ID and new claim | ||
*/ | ||
export function changeClaim(uid: string, new_claim: number) { | ||
const claims = { | ||
mobile_entry: new_claim == 0, | ||
web_entry: new_claim == 1, | ||
evaluator: new_claim == 2, | ||
admin: new_claim == 3 | ||
}; | ||
admin.auth().setCustomUserClaims(uid, claims) | ||
.catch( | ||
() => { | ||
console.log("ERROR: User with uid " + uid + " not found."); | ||
} | ||
) | ||
} | ||
|
||
export default { changeClaim }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"firebase-admin": "^11.11.0" | ||
} | ||
} |
Oops, something went wrong.