You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Letters sent holds an array of ids of letter that was successfully posted with Lob (payment and address verification went through)
User agreement is a boolean that they abide by the platforms outlined = community safety and protection guidelines
Updates is sending campaign_id so that we can send to advocacy groups so they can follow up and by our user education team
Directions
To save the user's phone number from Auth0 Universal Login to the constituent table, you can modify the up function of the migration file that creates the constituent table. Here are the steps you can follow:
1. Add a new column to the constituent table to store the phone number:
3. In your Express app, modify the /callback route to save the user's phone number to the constituent table:
router.get('/callback', passport.authenticate('auth0', {
failureRedirect: '/login'
}), async (req, res) => {
const { phone_number } = req.user._json // Get the phone number from the user object
const { name, email } = req.user // Get the name and email from the user object
try {
// Check if the user already exists in the constituent table
const existingConstituent = await knex('constituent').where({ email }).first()
if (existingConstituent) {
// Update the existing constituent with the phone number
await knex('constituent').where({ email }).update({ phone_number })
} else {
// Create a new constituent with the name, email, and phone number
await knex('constituent').insert({ name, email, phone_number })
}
res.redirect('/')
} catch (error) {
console.error(error)
res.status(500).send('Internal server error')
}
})
This code gets the phone number from the req.user._json object, which is provided by Passport when the user is authenticated. It then checks if the user already exists in the constituent table based on their email address. If the user exists, it updates their phone number. If the user does not exist, it creates a new constituent with the name, email, and phone number.
Note that you will need to import the knex object and the passport middleware in your Express app for this code to work.
The text was updated successfully, but these errors were encountered:
Goal: collect number from Auth0 login process and save into constituent table so we have the ability to send notifications later on
Background info
Constituent table lives within: amplify/server/db/migrations/20220413154827_rename-volunteers-table-to-constituents.js
Data types:
Directions
To save the user's phone number from Auth0 Universal Login to the constituent table, you can modify the up function of the migration file that creates the constituent table. Here are the steps you can follow:
This code gets the phone number from the req.user._json object, which is provided by Passport when the user is authenticated. It then checks if the user already exists in the constituent table based on their email address. If the user exists, it updates their phone number. If the user does not exist, it creates a new constituent with the name, email, and phone number.
The text was updated successfully, but these errors were encountered: