Hello guys. I have this question. In short, I made user authorization via Email & Phone. In short, it all works. The question is how do I add my data to this user. For example: I want to update the user’s location via GeoIP when authorizing a user, or simply add the login time to it.

If it’s not entirely clear, then there are user’s methods ( https://firebase.google.com/docs/reference/js/firebase.User ). I need the updateProfile method. Implementation of updateProfile from documentation:

 user.updateProfile({ displayName: "Jane Q. User", photoURL: "https://example.com/jane-q-user/profile.jpg" }).then(function() { var displayName = user.displayName; var photoURL = user.photoURL; }, function(error) { }); 

But this method only works with keys that already exist in the user. I mean, you can't add yours.

How can I add my data to the user? Database is not very suitable! thank

    1 answer 1

    Add an additional list in the Realtime Database of your project to store custom information for users.

    In rules, it will look something like this:

     { "rules": { ... "userinfo": { "$uid": { ".read": "$uid === auth.uid", ".write": "$uid === auth.uid" } }, ... } } 

    Thus, it will be possible to receive data.

    GET https: // {{project_name}} .firebaseio.com / userinfo / {{user_id}} .json? Auth = {{server_key}}

    And add your own

    POST https: // {{project_name}} .firebaseio.com / userinfo / {{user_id}} .json? Auth = {{server_key}}

     { "name": "Kirk", "gender": "MALE", "avatar": null, "birthDate": 1502463043 } 
    • Thank. This is a good method - Paul Kolesnyk