Should firebase auth onCreate trigger have more data?
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
add a comment |
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
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 thatdisplayName
is not populated in the Cloud FunctionsonCreate
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
add a comment |
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
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
firebase firebase-authentication google-cloud-functions
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 thatdisplayName
is not populated in the Cloud FunctionsonCreate
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
add a comment |
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 thatdisplayName
is not populated in the Cloud FunctionsonCreate
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
add a comment |
1 Answer
1
active
oldest
votes
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.
Thanks Frank. Is it firebase-ui making that second API call toupdateProfile
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 extendingcreateUserWithEmailAndPassword()
to allow additional, optional, data such asdisplayName
, so that the existingonCreate()
trigger could receive a more fully-populatedUserInfo
record. That would suit my needs in this case just as well. Tx.
– dsl101
Nov 21 '18 at 9:37
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Thanks Frank. Is it firebase-ui making that second API call toupdateProfile
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 extendingcreateUserWithEmailAndPassword()
to allow additional, optional, data such asdisplayName
, so that the existingonCreate()
trigger could receive a more fully-populatedUserInfo
record. That would suit my needs in this case just as well. Tx.
– dsl101
Nov 21 '18 at 9:37
add a comment |
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.
Thanks Frank. Is it firebase-ui making that second API call toupdateProfile
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 extendingcreateUserWithEmailAndPassword()
to allow additional, optional, data such asdisplayName
, so that the existingonCreate()
trigger could receive a more fully-populatedUserInfo
record. That would suit my needs in this case just as well. Tx.
– dsl101
Nov 21 '18 at 9:37
add a comment |
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.
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.
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 toupdateProfile
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 extendingcreateUserWithEmailAndPassword()
to allow additional, optional, data such asdisplayName
, so that the existingonCreate()
trigger could receive a more fully-populatedUserInfo
record. That would suit my needs in this case just as well. Tx.
– dsl101
Nov 21 '18 at 9:37
add a comment |
Thanks Frank. Is it firebase-ui making that second API call toupdateProfile
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 extendingcreateUserWithEmailAndPassword()
to allow additional, optional, data such asdisplayName
, so that the existingonCreate()
trigger could receive a more fully-populatedUserInfo
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 FunctionsonCreate
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