how can I get a user data using firebase authentication with email and password of an user?
the only way I was able to capture the user was to use the
firebase.auth() function.getUserByEmail(email)
but I don't find how to perform that call passing the email and password of the user, any help with this question?
my source code:
var express = require('express');
var app = express();
const firebase = require('firebase-admin');
const inquirer = require('inquirer')
const serviceAccount = require('...')
var currentUser;
var userProfile;
var config = {
credential: firebase.credential.cert(serviceAccount),
apiKey: "...",
authDomain: "...",
databaseURL: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "..."
};
firebase.initializeApp(config);
let server = app.listen('8081', function (err) {
if (err) {
console.log(err);
}
console.log("App listening on port " + "8081");
var authentication = [
{
type: 'input',
name: 'email',
message: "Type your email:",
},
{
type: 'password',
name: 'password',
message: "Type your password:",
},
]
inquirer.prompt(authentication).then(answers => {
console.log(`Hello! The application is starting!`)
startCrawler(answers['email'], answers['password'])
})
async () => {
await firebase.auth().getUserByEmail(email) //Here where I want to grab the user with email and password
.then((user) => {
currentUser = user.toJSON();
}).catch(err => {
console.log('Email or password invalid!');
});
if (!currentUser) { return };
}
});