Skip to content

Commit

Permalink
Updated connectionPatch.
Browse files Browse the repository at this point in the history
New parameter 'forceUnauthorized', which will set permissionsUpdated === true and clear connection endpoint_data.
This is to be used to allow users with long-updated connections (>3 days) to manually reset their connections.
  • Loading branch information
barankyle committed Jan 31, 2019
1 parent bdf45d3 commit 448c969
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion fixtures/maps/lyft.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"address": "string",
"time": "date"
}
}
},
"status": "string"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lifescope-api",
"version": "2.2.1",
"version": "2.2.2",
"description": "lifescope.io",
"author": "(https://lifescope.io)",
"repository": {
Expand Down
15 changes: 12 additions & 3 deletions schema/models/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ ConnectionTC.addResolver({
auth: {
status: {
complete: false
}
},
redirectUrl: authObj.redirectUrl
},
frequency: 1,
enabled: true,
Expand All @@ -369,7 +370,8 @@ ConnectionTC.addResolver({
id: 'String!',
enabled: 'Boolean',
permissions: 'JSON',
name: 'String'
name: 'String',
forceUnauthorized: 'Boolean',
},
resolve: async function({source, args, context, info}) {
let bitscoopConnection;
Expand Down Expand Up @@ -447,7 +449,7 @@ ConnectionTC.addResolver({
explorerConnection.enabled = args.enabled;
}

let permissionsUpdated = false;
let permissionsUpdated = args.forceUnauthorized === true;

_.each(permissions, function(value, name) {
if (!connection.permissions.hasOwnProperty(name)) {
Expand Down Expand Up @@ -546,6 +548,11 @@ ConnectionTC.addResolver({
}

explorerConnection.auth.redirectUrl = response.redirectUrl;
explorerConnection.last_run = null;

if (args.forceUnauthorized) {
explorerConnection.endpoint_data = {};
}
}
}

Expand All @@ -560,6 +567,8 @@ ConnectionTC.addResolver({

env.pubSub.publish('connectionUpdated', updateResult.record);

explorerConnection.id = args.id;

return {
connection: explorerConnection,
reauthorize: _.get(explorerConnection, 'auth.status.authorized', null) === false
Expand Down

0 comments on commit 448c969

Please sign in to comment.