casetext / firebase-admin

Programmatically instantiate and modify Firebase instances.
MIT License
18 stars 3 forks source link

using firebase admin to add users to auth and database give me anonymous #5

Closed nicolaselmir closed 7 years ago

nicolaselmir commented 7 years ago

Hey There !

Im using firebase with node js and express so I can create a user. when I do so it just give me this user as anonymous on the firebase dashboard and cant use it to login.

This is my code:

var express = require('express');
var router = express.Router();
var firebase = require('firebase');
var admin = require("firebase-admin");

router.post('/', function(req, res, next) {
  admin.auth().createUser({
  email: req.body.email,
  password: req.body.password,
})
.then(function(userRecord) {

    var name = req.body.name;
    var email = userRecord.email;
    var location = req.body.location;
    var phone = req.body.phone;
    var logo = req.body.logo;
    var category = req.body.category;
    var facebook = req.body.facebook;
    var twitter = req.body.twitter;
    var instagram = req.body.instagram;

admin.database().ref('/suppliers/' + userRecord.uid).set({
    id: userRecord.uid,
    name: name,
    email: email,
    location: location,
    phone: phone,
    logo: logo,
    category: category,
    facebookPage: facebook,
    twitterPage: twitter,
    instagramPage: instagram
  }).then(function(response){
  res.send(response);
})
}).catch(function(error) {
    console.log("Error creating new user:", error);
    res.send(err);
});

});

module.exports = router;
daguej commented 7 years ago

The firebase-admin package is no longer maintained by us and the code in this repo is old and unsupported.

See the v4 firebase-admin documentation or contact Firebase support if you have questions.