lib/functions/firebase.js
async function setUserInfo(auth) {
    try {
        const authenticated = await authWithFirebase(auth);
        const token = await firebase.auth().currentUser.getIdToken();
        const userId = firebase.auth().currentUser.uid;
        const userInfo = await getUserInfo(auth);
        userInfo.version = pjson.version;
        userInfo.lastLogin = {
            ".sv": "timestamp",
        };

        const infoUrl = `${constants.FIREBASE_DATABASE_URL}/users/${userId}.json?auth=${token}`;

        await request({
            url: infoUrl,
            method: "PATCH",
            json: true,
            headers: {
                "content-type": "application/json",
            },
            body: userInfo,
        });
        return true;
    } catch (err) {
        err.origin = 'setUserInfo';
        await error.log(err);
        return false;
    }
}
async function setUserInfo(auth) {
    try {
        const authenticated = await authWithFirebase(auth);
        const token = await firebase.auth().currentUser.getIdToken();
        const userId = firebase.auth().currentUser.uid;
        const userInfo = await getUserInfo(auth);
        userInfo.version = pjson.version;
        userInfo.lastLogin = {
            ".sv": "timestamp",
        };

        const infoUrl = `${constants.FIREBASE_DATABASE_URL}/users/${userId}.json?auth=${token}`;

        await request({
            url: infoUrl,
            method: "PATCH",
            json: true,
            headers: {
                "content-type": "application/json",
            },
            body: userInfo,
        });
        return true;
    } catch (err) {
        err.origin = 'setUserInfo';
        await error.log(err);
        return false;
    }
}
async function setUserInfo ( auth ) { try { const authenticated = await authWithFirebase ( auth ) ; const token = await firebase . auth ( ) . currentUser . getIdToken ( ) ; const userId = firebase . auth ( ) . currentUser . uid ; const userInfo = await getUserInfo ( auth ) ; userInfo . version = pjson . version ; userInfo . lastLogin = { ".sv" : "timestamp" , } ; const infoUrl = ` ${ constants . FIREBASE_DATABASE_URL } ${ userId } ${ token } ` ; await request ( { url : infoUrl , method : "PATCH" , json : true , headers : { "content-type" : "application/json" , } , body : userInfo , } ) ; return true ; } catch ( err ) { err . origin = 'setUserInfo' ; await error . log ( err ) ; return false ; } }
Log user to firebase

@param {google.auth.OAuth2} auth - An authorized OAuth2 client.
@returns {Promise} - a promise resolving true if user info has been set in firebase
Log user to firebase