fix: override fields update
This commit is contained in:
parent
1913390eae
commit
a432d913be
3 changed files with 10 additions and 3 deletions
|
|
@ -97,7 +97,7 @@ function update (id, data, userToken, txId) {
|
|||
*
|
||||
* @returns {Promise} Newly updated Customer
|
||||
*/
|
||||
async function updateCustomer (id, data) {
|
||||
async function updateCustomer (id, data, userToken) {
|
||||
const formattedData = _.pick(
|
||||
[
|
||||
'authorized_override',
|
||||
|
|
@ -110,7 +110,10 @@ async function updateCustomer (id, data) {
|
|||
],
|
||||
_.mapKeys(_.snakeCase, data))
|
||||
|
||||
const sql = Pgp.helpers.update(formattedData, _.keys(formattedData), 'customers') +
|
||||
const enhancedUpdateData = enhanceAtFields(enhanceOverrideFields(formattedData, userToken))
|
||||
const updateData = updateOverride(enhancedUpdateData)
|
||||
|
||||
const sql = Pgp.helpers.update(updateData, _.keys(updateData), 'customers') +
|
||||
' where id=$1'
|
||||
|
||||
await db.none(sql, [id])
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ const apolloServer = new ApolloServer({
|
|||
|
||||
const success = await login.authenticate(token)
|
||||
if (!success) throw new AuthenticationError('Authentication failed')
|
||||
return { req: { ...req } }
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -311,7 +311,10 @@ const resolvers = {
|
|||
machineAction: (...[, { deviceId, action, cassette1, cassette2, newName }]) => machineAction({ deviceId, action, cassette1, cassette2, newName }),
|
||||
createPairingTotem: (...[, { name }]) => pairing.totem(name),
|
||||
saveAccounts: (...[, { accounts }]) => settingsLoader.saveAccounts(accounts),
|
||||
setCustomer: (...[, { customerId, customerInput } ]) => customers.updateCustomer(customerId, customerInput),
|
||||
setCustomer: (root, args, context, info) => {
|
||||
const token = context.req.cookies && context.req.cookies.token
|
||||
return customers.updateCustomer(args.customerId, args.customerInput, token)
|
||||
},
|
||||
saveConfig: (...[, { config }]) => settingsLoader.saveConfig(config)
|
||||
.then(it => {
|
||||
notify()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue