firebase-functions: 0.5.7
firebase-tools: 3.9.0
firebase-admin: 4.2.1
This is the function index.js
const functions = require('firebase-functions')
const admin = require('firebase-admin')
// Initialize Admin with configuration
admin.initializeApp(functions.config().firebase)
exports.fillInitialUserProfile = functions.auth.user().onCreate((event) => {
const user = event.data
const db = admin.database()
return db.ref(`users/${user.uid}`).set({
displayName: user.displayName || `Member (${user.phoneNumber})`,
roles: []
})
})
There was no error during deployment of the functions
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (931 B) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: updating function fillInitialUserProfile...
✔ functions[fillInitialUserProfile]: Successful update operation.
✔ functions: all functions deployed successfully!
✔ Deploy complete!
users/.../* is emptyThanks for the report! You're entirely correct, we're currently not triggering functions for phone auth. This is a server-side bug, we'll work to get it fixed ASAP.
+1
I'm also not getting user.create events, using custom token auth here.
Ah, I'm sorry about that: we don't yet support triggering Cloud Functions (like auth.user().onCreate) on custom tokens auth. We do want to support that in the future, but we chose to launch without it so we could already bring the other forms of Auth triggers out. The same goes for Cloud Functions responding to login using anonymous tokens, which is also a future feature.
I also just realized that our documentation on Cloud Functions for Auth is very misleading in this regard; I'll fix that. Sorry about that!
@rjhuijsman, if implementations are going to take a long time, I suggest to clarify things in the documentations first. Like what works, and which feature is missing for some parts.
It's really not cool to get excited about a new feature announcement, only to find-out it's not fully supported yet. I'd rather hear warnings along with the announcement, or in the documentations, than to spend time aligning my app to use the feature, and spend hours on why it's not working as expected; and then someone officially announce it's not fully supported yet.
Thanks so much for the feedback @eliezedeck. You are absolutely right in saying that it is better to document what is being supported and not rather than to have users spend time discovering gaps experimentally. We are sorry for the disappointment and time waste you experienced. This was not intentional, and we hope to prevent things like this from happening in the future!
Thank you @laurenzlong for your being professional. I also appreciate you taking the time for talking to us developers as I know you lead the Firebase team in the "Firebase Functions" area. It really shows your commitment to making developer experiences better.
Please, do let us know if there are things we can help you guys with. I personally, would love to help in any way I can.
I'm developing an app on the weekends which will be used by Seventh-day Adventist church members, hopefully all over the world, running 100% on Firebase, for church management, member communications, etc... It's just starting-up, but I'll keep bug reports and inconsistencies coming so we can all have a better platform for our apps; I also have some feature requests and I'll report them next time.
@laurenzlong and @rjhuijsman, what I would love is to have all bug reports here on Github if possible, not just for Functions feature. Like having Firebase functions here is really a breeze. Github is accessible, it's more open, and easy for us developers to interact with, and we're more accustomed to it (less formality is a huge bonus). I think that's important for a platform that needs actual feedbacks from more people using it like very often.
I know it's a bit off-topic, much of this post and I'm sorry about that, but I really hope it helps in some ways.
Thanks again @eliezedeck! If you have any bug reports for Cloud Functions for Firebase, please do feel free to open issues here. We now also have open-sourced client SDKs for many of the other Firebase features, please also do report any bugs for those!
It's great to know that the public GitHub issues are appreciated, I think everybody on the Firebase team also likes the direct communications!
As for the documentation, we're working on fixing that right now. Thanks!
Thanks for the patience & kind words @eliezedeck, and that's a cool use case!
I actually don't lead Cloud Functions for Firebase, that would be @inlined :) I do lead our efforts on the SDK and CLI, and definitely appreciate Github as a transparent forum to hear feedback from supportive developers like you!
Phone Auth now triggers Cloud Functions, as intended. Here's an example of the UserRecord object (in event.data) that you might receive:
{
"metadata": {
"createdAt": "2017-06-01T23:01:23.000Z",
"lastSignedInAt": "2017-06-01T23:01:23.000Z"
},
"phoneNumber": "+1555123456",
"providerData": [
{
"providerId": "phone",
"uid": "+1555123456"
}
],
"uid": "C6simWCCNlO3Mdyq9PYyY1O8qPJ3"
}
For TypeScript users, the catch is that the phoneNumber field isn't in our TypeScript definition for the UserRecord yet. I've filed an issue to track that. In the mean time, consider getting the phone number from providerData.uid field instead.
Thanks again for the reports everyone.
@rjhuijsman Is there any ETA for trigger to work when creating user with custom token?
I'm sorry, I can't give you any timelines. I'll let the team know you asked though!
I also need triggers for custom tokens
@rjhuijsman An onCreate event handler for custom auth tokens is definitely something I'd love to see implemented as well. I understand it's not a simple implementation, so thanks for keeping it in mind.
Want to clarify, the website doesn't say phone auth is supported! But @rjhuijsman mentioned it works in 2017. Did things change since then?
Phone Auth supported as a trigger per this comment. Closing this out to prevent more follow ons. Custom token support should be tracked in a separate issue and debugging issues should be handled by creating a minimal repro demonstrating a bug at our end and creating a new issue.
Most helpful comment
@rjhuijsman An onCreate event handler for custom auth tokens is definitely something I'd love to see implemented as well. I understand it's not a simple implementation, so thanks for keeping it in mind.