Is it possible to create users (email/password type) from inside the Cloud Functions? I am searching for reference to this, but found nothing.
Use this Http based function to make the endpoint to create users.
the link would be something like this. https://us-central1-FIREBASE-PROYECT.cloudfunctions.net/register
exports.register = functions.https.onRequest((request,response)=>{
if (request.method !== "POST") {
response.status(400).send("what are you trying baby?");
return 0;
}
const email = request.body.email;
const pass = request.body.pass;
admin.auth().createUser({
email: email,
emailVerified: true,
password: pass,
})
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log("Conductor " + email + "Creado" );
response.send({"uid":userRecord.uid});
return 1;
})
.catch(function(error) {
response.send("Error: "+error);
console.log("Error creating new user:", error);
return 1;
});
return 1;
});