Changing authorization on the update execution
This commit is contained in:
1 parent
3f4e90f98f
commit
43cff60e95
1 file changed
+8
-9
@@ -8,8 +8,6 @@ import {
|
||||
import { OperationsError } from '../../errors'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
import teamQuery from '../../graphQLCalls/teamQuery'
|
||||
import cloneDetails from '../cloneDetails'
|
||||
import { isDefined } from '../../config/utils'
|
||||
|
||||
const args = {
|
||||
@@ -25,15 +23,20 @@ const args = {
|
||||
}
|
||||
|
||||
const resolve = async (parent,
|
||||
{ id, summaryDate, buyAverage, sellAverage, marketRate, combinedProfitsA,
|
||||
combinedProfitsB, assetA, assetB
|
||||
}, context) => {
|
||||
{ id, summaryDate, buyAverage, sellAverage, marketRate, combinedProfitsA,
|
||||
combinedProfitsB, assetA, assetB
|
||||
}, context) => {
|
||||
logger.debug('UpdateExecutionSummary -> Entering Function.')
|
||||
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
|
||||
if (!(context.userId === process.env.AACLOUD_ID)) {
|
||||
logger.debug('User %s is not authorized to manage team %s.', authId, team.slug)
|
||||
throw new AutorizationError()
|
||||
}
|
||||
|
||||
try {
|
||||
let clone = await Clone.findOne({
|
||||
_id: id,
|
||||
@@ -44,10 +47,6 @@ const resolve = async (parent,
|
||||
return 'Clone not found.'
|
||||
}
|
||||
|
||||
let allUserBotsResponse = await teamQuery(context.authorization, clone.botId)
|
||||
let bot = allUserBotsResponse.data.data.teams_FbByOwner.edges[0].node
|
||||
clone = cloneDetails(bot, clone)
|
||||
|
||||
const query = { _id: id }
|
||||
const options = { new: true }
|
||||
const update = {
|
||||
|
||||
Reference in new issue
Block a user