0

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 };
    }

});
1
  • 1
    You can't get a plaintext password for a user. That's a security problem. Commented Apr 15, 2019 at 3:32

1 Answer 1

2

It looks like you're trying to sign the user in on a Node.js app that uses the Firebase Admin SDK. The Firebase Admin SDK doesn't have the concept of a signed in user. If you need that, consider using the regular Firebase SDK for web applications.

Also see my answer here: Firebase Admin SDK to Log user in from Server

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.