Created
September 4, 2019 10:12
-
-
Save shark-h/b3b70fb76c1c64013d2e48a27f4f9ff3 to your computer and use it in GitHub Desktop.
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
// REGISTER USER WITH REQUIRED CUSTOM CLAIMS | |
exports.registerUser = functions.https.onCall(async (data, context) => { | |
const email = data.email; | |
const password = data.password; | |
const displayName = data.displayName; | |
if (email == null || password == null || displayName == null) { | |
throw new functions.https.HttpsError('signup-failed', 'missing information'); | |
} | |
try { | |
var userRecord = await admin.auth().createUser({ | |
email: email, | |
password: password, | |
displayName: displayName | |
}); | |
const customClaims = { | |
"https://hasura.io/jwt/claims": { | |
"x-hasura-default-role": "user", | |
"x-hasura-allowed-roles": ["user"], | |
"x-hasura-user-id": userRecord.uid | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment