Last active
June 20, 2019 10:54
-
-
Save luandevpro/afe0679531b26d6a65c8847174c0ab48 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
const functions = require('firebase-functions'); | |
const admin = require('firebase-admin'); | |
admin.initializeApp(functions.config().firebase); | |
// On sign up. | |
exports.processSignUp = functions.auth.user().onCreate(user => { | |
return admin | |
.auth() | |
.setCustomUserClaims(user.uid, { | |
'https://hasura.io/jwt/claims': { | |
'x-hasura-default-role': 'user', | |
'x-hasura-allowed-roles': ['user'], | |
'x-hasura-user-id': user.uid, | |
}, | |
}) | |
.then(() => { | |
const metadataRef = admin.database().ref(`metadata/${user.uid}`); | |
return metadataRef.set({ refreshTime: new Date().getTime() }); | |
}) | |
.catch(error => { | |
console.log(error); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment