What is the best way to send a user-provided input to my cloud function?

Currently, I am delving into the realm of Cloud Functions for Firebase and have successfully implemented an auth trigger by following a tutorial. However, I am now facing a challenge in passing the username that the user desires to use to my auth event. I am uncertain if I selected the incorrect trigger and whether an HTTP trigger would have been more suitable?

exports.newUserSignup = functions.auth.user().onCreate(user => {
  console.log('user created', user.email, user.uid);
  const doc = admin.firestore().collection('users').doc();
  return doc.set({
    createDate: admin.firestore.FieldValue.serverTimestamp(),
    modifiedDate: admin.firestore.FieldValue.serverTimestamp(), 
    username: 'NEED TO FIGURE THIS OUT',
    email: user.email,    
    stat: 1,
    uid: user.uid,
    rowpointer: doc.id,
  });
});

Answer №1

There is currently no method to provide additional information to the auth.user().onCreate trigger, and unfortunately, there is no way to activate it when the account is updated.

You have two main choices:

  1. Create the document using your application code after creating the account.
  2. Send all data to a Callable or HTTP Cloud Function, allowing it to manage both account creation and Firestore writing.

Both options are equally valid, so choose the one that makes the most sense for you.

For more details, check out:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to avoid bracket issues in Android Studio?

I have just made the switch from Eclipse to Android Studio and I find myself missing the feature where you could press tab to escape brackets in Eclipse. Is there a similar shortcut in Android Studio that allows for this, instead of having to use the mou ...

The 'MY_EVENTS_LOAD' argument is incompatible with the 'TakeableChannel<unknown>' parameter in the yeild takeLatest function

I am encountering a TypeScript error while using Redux and Saga as middleware. The error message is as follows: No overload matches this call. The last overload gave the following error. Argument of type '"MY_EVENTS_LOAD"' is not assignabl ...

Eliminate redundant sets of comma-separated numbers from the jQuery input text value

On my webpage, there is an input with a value that looks like this: 1,7,1,4,22,58,58,1,1,4,7 <input type="text" name="hello" id="thankyouforhelping" value="" aria-invalid="false"> I have attempted mu ...

Is there a method to uncover the code that controls the display of a <div> element?

As a fresh face at the company, I've been given the responsibility of developing a chart that is similar to one already present on their website. While I have the knowledge and skills to create it, I am struggling to locate the specific code where the ...

Updating the value of a JSON data attribute

I am looking to update a specific value in a JSON array. To provide more context, here is the DOM structure I have: <input class="fileupload" type="file" data-form-data='{"table_reference": "data_monitoring", "table_token" : "X43sd"}'> I ...

Include html into typescript using webpack

Attempting to include HTML content into a variable using TypeScript and webpack has been my challenge. This is the current setup: package.json: { "devDependencies": { "awesome-typescript-loader": "^3.2.3", "html-loader": "^0.5.1", "ts-load ...

Preserve information on page reload in AngularJS

I am currently working on an AngularJS application with Spring REST as the backend. My experience with AngularJS is quite new. Within my UI page, I have a table displaying a list of objects with an edit button for each record. Clicking the edit button ope ...

What is the best way to apply a mask to a textbox to format the date as MM/yyyy using a mask

In my asp.net application, I have a TextBox for entering Credit card date (month & year only). I tried using the 'TextBox with masked edit extender' and set Mask="99/9999" with Mask Type="Date. However, it is not working as expected - it only wor ...

Utilizing NPM Package Configuration Variables with Docker Commands: A Guide

I have a unique file structure where my package.json contains a single variable called settings which defines the port for the application: package.json ... "settings":{ "port": "3000" }, ... In addition, I've set up a custom script to execute a ...

Creating a Modal Popup

My objective is to trigger a modal popup when a button is clicked during an event. I have encountered challenges in utilizing the Axios API to call the function that initiates the modal. Below is the sequence of the API call process: First: The button whe ...

Shifting JavaScript from Client to Server in Node/Express: A Step-by-Step Guide

Within my .handlebars file, I have a combination of HTML and JS code (provided below). The code represents a basic form which users can expand by clicking on a "New Form Field" button. Clicking on this button will simply add a new text field to the form. U ...

Using Functions outside of React Components

I am having trouble figuring out how to update a shopping cart when I click on a product. The function is written in one component, but I need to call it from another. Here is where the function is defined and the cart state is maintained: export const ...

What is the best way to determine the number of connections in Redis when using Node.js?

Is it possible to retrieve the number of current connections to the Redis database using Node.js? const redis = require('redis'); var client = redis.createClient(port, host); client.on('connect', () => { //Retrieve and display th ...

Error message encountered when attempting to rotate an object in three.js: "Object is undefined"

Experiencing an "Undefined Object" error while attempting to rotate an object using three.js. Here is a snippet of the code in question: var object; function render() { renderer.render(scene, camera); } function animate() { object.rotation.x + ...

Button element experiencing unexpected issues with ng-disabled in AngularJS

I've implemented a new button that should be active when the page loads and then disabled when data is being saved (using a save button). Essentially, this new button should be inactive whenever the save button is active. Angular code : <input id ...

Encountered React error: Cannot assign type 'string | string[]' to type 'string[]'

I am brand new to React but have a good grasp on vanilla JS, and I've been following a YouTube tutorial. The tutorial took a different approach in this section which is why I need some guidance. Essentially, I'm defining an 'interface ListP ...

Establishing Node.js environment variables when invoking `npm run` command

package.json { "scripts": { "start": "NODE_ENV=development node ./index.js" } } If we wanted to pass and override NODE_ENV when running npm run start, is it possible? npm run start NODE_ENV=production ...

Unable to receive a response after attempting to send an email through XMLHttpRequest

I have been struggling to send emails even after editing the template. I am currently working on creating a subscription box and here is the code I have so far: var x= document.getElementById("emailtxt").value; var uploadFormData = new FormData(); upload ...

Adding to the beginning of a list in JQuery mobile

Having trouble figuring out how to prepend my list in jQuery mobile while keeping the divider on top of the most recent item added. I attempted to prepend the newly added item, but it ended up shifting the divider to the bottom instead. function loadScan ...

Can you explain the distinction between object allocation using the '=&' operator and the Object.create() method?

I have been delving deep into JavaScript object operations. My question revolves around the difference between const me = Object.create(person); and const me = person;. Both of these operations provide a similar output as they reference the object to a new ...