Skip to content

Instantly share code, notes, and snippets.

@shark-h
Created September 4, 2019 10:12
Show Gist options
  • Save shark-h/b3b70fb76c1c64013d2e48a27f4f9ff3 to your computer and use it in GitHub Desktop.
Save shark-h/b3b70fb76c1c64013d2e48a27f4f9ff3 to your computer and use it in GitHub Desktop.
// 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