Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
How do i input database in firestore with user's input for name of the document?

I have a problem with my api. I want to use the firestore to input data for login & register with APi. Then, when i want to add the document database with user's input email when register but the output is error. my reasons for adding document with user's email is for easier for the next login step for its validation to compare the password also the email. here the code that i already make:

const functions = require("firebase-functions");
const express = require("express");
// eslint-disable-next-line no-unused-vars
const cors = require("cors");

const admin = require("firebase-admin");
admin.initializeApp();

const app = express();
const db = admin.firestore();

app.post("/Register", (req, res) => {
  const {
    name,
    email,
    password,
    phone,
  } = req.body;
  const saldo = 0;
  const valAcc = db.collection("Users").doc(email);
  valAcc.get().then((doc) => {
    if (doc.exists) {
      res.status(409).send("User Already Exist!");
    }
  });
  db.collection("Users").doc(email).add({
    Name: name,
    Email: email,
    Password: password,
    Phone: phone,
    Saldo: saldo,
  });
  res.status(201).send();
});

exports.apptest = functions.https.onRequest(app);

Do you guys have any solution? rly appriciate for any help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't recommend handling user authentication yourself. I recommend using Firebase built-in tool for this instead: Firebase Authentication

With this, it's easy to implement email/passwords or providers (google, facebook etc) login.

And it's probably much safer than doing from scratch.

Afterwards you can use the UID or email of the logged user for storing/retrieving data on Firestore.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda