Firebase v3 Auth offers an updateProfile
method that passes displayName
and photoURL
to Firebase.
My understanding is that these properties are retrieved from 3rd party oAuth providers Google, Facebook, Twitter, or GitHub upon user login. In case of Password based Auth, they are not available or viewable from the Admin console.
Can I store this info for password Auth accounts, and if so can I view/administer this info via the Admin console?
BTW: I know this could be stored in the Realtime Database under a users
node/branch but I am asking about storing this info in the Firebase Auth system.
// Updates the user attributes:
user.updateProfile({
displayName: "Jane Q. User",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
// Profile updated successfully!
// "Jane Q. User"
var displayName = user.displayName;
// "https://example.com/jane-q-user/profile.jpg"
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
// Passing a null value will delete the current attribute's value, but not
// passing a property won't change the current attribute's value:
// Let's say we're using the same user than before, after the update.
user.updateProfile({photoURL: null}).then(function() {
// Profile updated successfully!
// "Jane Q. User", hasn't changed.
var displayName = user.displayName;
// Now, this is null.
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
.updateProfile
stores the displayName
and photoURL
properties in the Firebase Auth system. Therefore, there is no need to set/get this stuff under a users
node in your Realtime Database.
You will not see these properties in the Firebase v3 Auth Console. It's not viewable that way.
Rolled into one, here how to register a password user:
registerPasswordUser(email,displayName,password,photoURL){
var user = null;
//nullify empty arguments
for (var i = 0; i < arguments.length; i++) {
arguments[i] = arguments[i] ? arguments[i] : null;
}
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function () {
user = firebase.auth().currentUser;
user.sendEmailVerification();
})
.then(function () {
user.updateProfile({
displayName: displayName,
photoURL: photoURL
});
})
.catch(function(error) {
console.log(error.message);
});
console.log('Validation link was sent to ' + email + '.');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With