FEAT: Update OAuth Connection

This commit is contained in:
Victor Radael
2022-12-20 17:01:00 -03:00
parent 0fc8c427a2
commit 190a63f0eb
3 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -3297,7 +3297,7 @@
}
},
"info": {
"title": "Maestro - fix/refresh-token",
"title": "Maestro - feat/update-connection",
"description": "Documentation for Maestro gateway",
"version": "1.0.0",
"contact": {}
+10 -4
View File
@@ -148,10 +148,16 @@ export class OauthController {
const { customer_id, customer_name, user_id } = connectionInfo;
try {
const response = await this.connectionService.createConnection(
connectionInfo,
PackTheMetadata({ customer_id, customer_name, user_id }),
);
const response = connectionInfo.id
? await this.connectionService.updateConnection(
connectionInfo.id,
connectionInfo,
PackTheMetadata({ customer_id, customer_name, user_id }),
)
: await this.connectionService.createConnection(
connectionInfo,
PackTheMetadata({ customer_id, customer_name, user_id }),
);
url.searchParams.set('connection_id', response.connection.id);
return { url: url.href };
} catch (error) {
+2
View File
@@ -23,6 +23,7 @@ export class OauthService {
user_id,
customer_id,
customer_name,
id,
} = query;
const properties = { plugin, credentials_type: 'oauth' };
@@ -45,6 +46,7 @@ export class OauthService {
type,
properties,
plugin,
id,
};
return jwt.sign({ ...newConnection }, process.env.JWT_PRIVATE_KEY);
}