Save login number to constituent table
@EmaleeSoto ya está trabajando en esto.
Desde el 16/11/2023.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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:
- name is a string
- Street address, City, and State are strings
- Zipcode is a string
- 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:
exports.up = function(knex) {
return knex.schema.createTable('constituent', (table) => {
table.increments('id').primary()
table.string('name').notNullable()
table.string('email').notNullable().unique()
table.string('phone_number') // Add this line
table.timestamps(true, true)
})
}
- 2. Modify the down function of the migration file to drop the phone_number column:
exports.down = function(knex) {
return knex.schema.dropTable('constituent')
}
- 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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 120
- Forks
- 101
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de OpenSourceFellows/amplify
-
QA Bug Part 2 Update Axios-cache-InterceptionQuizá libre de nuevo @SAUMILDHANKAR la tomó hace 355 días y no hay ningún pull request abierto. Abiertobug Failing workflow check
OpenSourceFellows/amplify#1077 · 4 comentarios · 2 asignados ·
-
Auto messages for Pull RequestQuizá libre de nuevo @Alex-is-Gonzalez la tomó hace 355 días y no hay ningún pull request abierto. Abierto
OpenSourceFellows/amplify#1076 · 2 comentarios · 1 asignado ·
-
Add Auto Reviewer to PRAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
OpenSourceFellows/amplify#1075 ·
-
new contributor
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
OpenSourceFellows/amplify#1059 · 1 comentario ·
-
Pick your own ActionAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
OpenSourceFellows/amplify#1058 · 1 comentario ·
Todos los issues de OpenSourceFellows/amplify
Issues similares
-
新讀者走讀回報,照著一篇文章實際操作Abiertodocumentation good first issue help wanted
Dificultad 1/5 1-3 horas Aptitud para principiantes 92/100
Los mantenedores suelen responder en 1 día
-
automated issue report
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
lirantal/discoprint#29 ·
Los mantenedores suelen responder en 1 día
-
RSS feed autodiscoveryAbiertofeature-request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
louislam/uptime-kuma#7914 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Code Cleanup dependencies
Dificultad 1/5 Menos de una hora Aptitud para principiantes 68/100
ProjectSidewalk/SidewalkWebpage#5609 ·
Los mantenedores suelen responder en 1 día
-
help wanted javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
OWASP/cornucopia#3538 ·
Los mantenedores suelen responder en 1 día