2016-07-25 9 views
3

Firebase v3 Auth bietet eine updateProfile-Methode, die an Firebase displayName und photoURL übergibt.Firebase v3 updateProfile-Methode

Mein Verständnis ist, dass diese Eigenschaften von Drittanbieter-oAuth-Anbieter Google, Facebook, Twitter oder GitHub nach Benutzeranmeldung abgerufen werden. Im Fall von Password-based Auth sind sie nicht verfügbar oder über die Admin-Konsole sichtbar.

Kann ich diese Informationen für Passwort-Auth-Konten speichern, und wenn ja, kann ich diese Informationen über die Admin-Konsole anzeigen/verwalten?

BTW: Ich weiß, dass dies in der Realtime-Datenbank unter einem users Knoten/Zweig gespeichert werden könnte, aber ich frage nach dem Speichern dieser Informationen im Firebase Auth-System.

enter image description here

// 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. 
}); 

Antwort

3

.updateProfile speichert die displayNamephotoURL und Eigenschaften in der Firebase Auth-System. Daher ist es nicht notwendig, dieses Zeug unter einen users Knoten in Ihrer Echtzeitdatenbank zu setzen.

Diese Eigenschaften werden in der Firebase v3 Auth Console nicht angezeigt. Es ist nicht sichtbar so.

in einem, hier wie ein Benutzer-Passwort registrieren:

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 + '.'); 
}