Should firebase auth onCreate trigger have more data?












0















I'm using functions.auth.user().onCreate() as part of a firestore project, and trying to set up some default data when a new user registers. For the front end, I'm using firebase-ui, with Google and Email/Password providers enabled.



When I sign in with an email and password, the UI widget prompts to enter a name and set a password. I was expecting to see the name as part of the user parameter in the onCreate() function call, but I'm getting practically nothing:



user: { email: 'xxx@yyyy.co.uk',
emailVerified: false,
displayName: null,
photoURL: null,
phoneNumber: null,
disabled: false,
providerData: ,
customClaims: {},
passwordSalt: null,
passwordHash: null,
tokensValidAfterTime: null,
metadata:
UserRecordMetadata {
creationTime: '2018-11-20T15:06:01Z',
lastSignInTime: '2018-11-20T15:06:01Z' },
uid: 'QDJ5OJTwbvNo2QNDVQV9VsxC2pz2',
toJSON: [Function] }


Not even getting the provider info so I can tell which 'kind' of user registered. It's almost like this function is triggered before the user record has been populated (except the email address does get through). Also, registrations via the Google provider come with a fully-populated user record, so I guess this is a problem with Email/Password specifically.



Is this a bug, or am I missing something? I didn't see anything else useful in the context parameter either.










share|improve this question























  • I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

    – dsl101
    Nov 20 '18 at 15:42













  • The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

    – Frank van Puffelen
    Nov 20 '18 at 17:40
















0















I'm using functions.auth.user().onCreate() as part of a firestore project, and trying to set up some default data when a new user registers. For the front end, I'm using firebase-ui, with Google and Email/Password providers enabled.



When I sign in with an email and password, the UI widget prompts to enter a name and set a password. I was expecting to see the name as part of the user parameter in the onCreate() function call, but I'm getting practically nothing:



user: { email: 'xxx@yyyy.co.uk',
emailVerified: false,
displayName: null,
photoURL: null,
phoneNumber: null,
disabled: false,
providerData: ,
customClaims: {},
passwordSalt: null,
passwordHash: null,
tokensValidAfterTime: null,
metadata:
UserRecordMetadata {
creationTime: '2018-11-20T15:06:01Z',
lastSignInTime: '2018-11-20T15:06:01Z' },
uid: 'QDJ5OJTwbvNo2QNDVQV9VsxC2pz2',
toJSON: [Function] }


Not even getting the provider info so I can tell which 'kind' of user registered. It's almost like this function is triggered before the user record has been populated (except the email address does get through). Also, registrations via the Google provider come with a fully-populated user record, so I guess this is a problem with Email/Password specifically.



Is this a bug, or am I missing something? I didn't see anything else useful in the context parameter either.










share|improve this question























  • I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

    – dsl101
    Nov 20 '18 at 15:42













  • The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

    – Frank van Puffelen
    Nov 20 '18 at 17:40














0












0








0








I'm using functions.auth.user().onCreate() as part of a firestore project, and trying to set up some default data when a new user registers. For the front end, I'm using firebase-ui, with Google and Email/Password providers enabled.



When I sign in with an email and password, the UI widget prompts to enter a name and set a password. I was expecting to see the name as part of the user parameter in the onCreate() function call, but I'm getting practically nothing:



user: { email: 'xxx@yyyy.co.uk',
emailVerified: false,
displayName: null,
photoURL: null,
phoneNumber: null,
disabled: false,
providerData: ,
customClaims: {},
passwordSalt: null,
passwordHash: null,
tokensValidAfterTime: null,
metadata:
UserRecordMetadata {
creationTime: '2018-11-20T15:06:01Z',
lastSignInTime: '2018-11-20T15:06:01Z' },
uid: 'QDJ5OJTwbvNo2QNDVQV9VsxC2pz2',
toJSON: [Function] }


Not even getting the provider info so I can tell which 'kind' of user registered. It's almost like this function is triggered before the user record has been populated (except the email address does get through). Also, registrations via the Google provider come with a fully-populated user record, so I guess this is a problem with Email/Password specifically.



Is this a bug, or am I missing something? I didn't see anything else useful in the context parameter either.










share|improve this question














I'm using functions.auth.user().onCreate() as part of a firestore project, and trying to set up some default data when a new user registers. For the front end, I'm using firebase-ui, with Google and Email/Password providers enabled.



When I sign in with an email and password, the UI widget prompts to enter a name and set a password. I was expecting to see the name as part of the user parameter in the onCreate() function call, but I'm getting practically nothing:



user: { email: 'xxx@yyyy.co.uk',
emailVerified: false,
displayName: null,
photoURL: null,
phoneNumber: null,
disabled: false,
providerData: ,
customClaims: {},
passwordSalt: null,
passwordHash: null,
tokensValidAfterTime: null,
metadata:
UserRecordMetadata {
creationTime: '2018-11-20T15:06:01Z',
lastSignInTime: '2018-11-20T15:06:01Z' },
uid: 'QDJ5OJTwbvNo2QNDVQV9VsxC2pz2',
toJSON: [Function] }


Not even getting the provider info so I can tell which 'kind' of user registered. It's almost like this function is triggered before the user record has been populated (except the email address does get through). Also, registrations via the Google provider come with a fully-populated user record, so I guess this is a problem with Email/Password specifically.



Is this a bug, or am I missing something? I didn't see anything else useful in the context parameter either.







firebase firebase-authentication google-cloud-functions






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 15:24









dsl101dsl101

650614




650614













  • I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

    – dsl101
    Nov 20 '18 at 15:42













  • The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

    – Frank van Puffelen
    Nov 20 '18 at 17:40



















  • I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

    – dsl101
    Nov 20 '18 at 15:42













  • The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

    – Frank van Puffelen
    Nov 20 '18 at 17:40

















I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

– dsl101
Nov 20 '18 at 15:42







I think it's a slightly different scenario, since my client-side code isn't actually creating the account, and the user doesn't have write access to the firestore collection I want to update (hence using a triggered cloud function). But, are you saying that the prompt 'First & last name' when using firebase-ui is never made available to the triggered function?

– dsl101
Nov 20 '18 at 15:42















The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

– Frank van Puffelen
Nov 20 '18 at 17:40





The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call, while the display name is set with a second API call.

– Frank van Puffelen
Nov 20 '18 at 17:40












1 Answer
1






active

oldest

votes


















1














The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call (createUserWithEmailAndPassword()), while the display name is set with a second API call (updateProfile).



The usual workaround would be to create a Cloud Function to update the user profile, as shown here: Firebase Auth+Functions | create user with displayName



I also highly recommend filing a feature request to be able to have a Cloud Function triggered on profile changes.






share|improve this answer
























  • Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

    – dsl101
    Nov 20 '18 at 21:59











  • I think FirebaseUI does that for you.

    – Frank van Puffelen
    Nov 20 '18 at 22:59











  • Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

    – dsl101
    Nov 21 '18 at 9:37













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396227%2fshould-firebase-auth-oncreate-trigger-have-more-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call (createUserWithEmailAndPassword()), while the display name is set with a second API call (updateProfile).



The usual workaround would be to create a Cloud Function to update the user profile, as shown here: Firebase Auth+Functions | create user with displayName



I also highly recommend filing a feature request to be able to have a Cloud Function triggered on profile changes.






share|improve this answer
























  • Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

    – dsl101
    Nov 20 '18 at 21:59











  • I think FirebaseUI does that for you.

    – Frank van Puffelen
    Nov 20 '18 at 22:59











  • Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

    – dsl101
    Nov 21 '18 at 9:37


















1














The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call (createUserWithEmailAndPassword()), while the display name is set with a second API call (updateProfile).



The usual workaround would be to create a Cloud Function to update the user profile, as shown here: Firebase Auth+Functions | create user with displayName



I also highly recommend filing a feature request to be able to have a Cloud Function triggered on profile changes.






share|improve this answer
























  • Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

    – dsl101
    Nov 20 '18 at 21:59











  • I think FirebaseUI does that for you.

    – Frank van Puffelen
    Nov 20 '18 at 22:59











  • Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

    – dsl101
    Nov 21 '18 at 9:37
















1












1








1







The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call (createUserWithEmailAndPassword()), while the display name is set with a second API call (updateProfile).



The usual workaround would be to create a Cloud Function to update the user profile, as shown here: Firebase Auth+Functions | create user with displayName



I also highly recommend filing a feature request to be able to have a Cloud Function triggered on profile changes.






share|improve this answer













The fact that displayName is not populated in the Cloud Functions onCreate trigger for email+password is expected. The function is triggered from the first API call (createUserWithEmailAndPassword()), while the display name is set with a second API call (updateProfile).



The usual workaround would be to create a Cloud Function to update the user profile, as shown here: Firebase Auth+Functions | create user with displayName



I also highly recommend filing a feature request to be able to have a Cloud Function triggered on profile changes.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 18:00









Frank van PuffelenFrank van Puffelen

232k29380405




232k29380405













  • Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

    – dsl101
    Nov 20 '18 at 21:59











  • I think FirebaseUI does that for you.

    – Frank van Puffelen
    Nov 20 '18 at 22:59











  • Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

    – dsl101
    Nov 21 '18 at 9:37





















  • Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

    – dsl101
    Nov 20 '18 at 21:59











  • I think FirebaseUI does that for you.

    – Frank van Puffelen
    Nov 20 '18 at 22:59











  • Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

    – dsl101
    Nov 21 '18 at 9:37



















Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

– dsl101
Nov 20 '18 at 21:59





Thanks Frank. Is it firebase-ui making that second API call to updateProfile when email/password is the login method? Or does that need to be explicitly done in the client?

– dsl101
Nov 20 '18 at 21:59













I think FirebaseUI does that for you.

– Frank van Puffelen
Nov 20 '18 at 22:59





I think FirebaseUI does that for you.

– Frank van Puffelen
Nov 20 '18 at 22:59













Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

– dsl101
Nov 21 '18 at 9:37







Thanks—feature request submitted. I also suggested maybe extending createUserWithEmailAndPassword() to allow additional, optional, data such as displayName, so that the existing onCreate() trigger could receive a more fully-populated UserInfo record. That would suit my needs in this case just as well. Tx.

– dsl101
Nov 21 '18 at 9:37




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396227%2fshould-firebase-auth-oncreate-trigger-have-more-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

How to fix TextFormField cause rebuild widget in Flutter

Npm cannot find a required file even through it is in the searched directory