1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-11-11 01:28:58 +03:00

fix(editor): Issue showing Auth2 callback section when all properties are overriden (#8999)

This commit is contained in:
Ricardo Espinoza 2024-04-04 05:30:37 -04:00 committed by GitHub
parent bc6575afbb
commit dff8f7ac94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 2 deletions

View File

@ -236,4 +236,29 @@ describe('Credentials', () => {
.find('input')
.should('have.value', NEW_QUERY_AUTH_ACCOUNT_NAME);
});
it('should not show OAuth redirect URL section when OAuth2 credentials are overridden', () => {
cy.intercept('/types/credentials.json', { middleware: true }, (req) => {
req.headers['cache-control'] = 'no-cache, no-store';
req.on('response', (res) => {
const credentials = res.body || [];
const index = credentials.findIndex((c) => c.name === 'slackOAuth2Api');
credentials[index] = {
...credentials[index],
__overwrittenProperties: ['clientId', 'clientSecret'],
};
});
});
workflowPage.actions.visit(true);
workflowPage.actions.addNodeToCanvas('Slack');
workflowPage.actions.openNode('Slack');
workflowPage.getters.nodeCredentialsSelect().click();
getVisibleSelect().find('li').last().click();
credentialsModal.getters.credentialAuthTypeRadioButtons().first().click();
nodeDetailsView.getters.copyInput().should('not.exist');
});
});

View File

@ -78,7 +78,7 @@
/>
<CopyInput
v-if="isOAuthType && credentialProperties.length"
v-if="isOAuthType && !allOAuth2BasePropertiesOverridden"
:label="$locale.baseText('credentialEdit.credentialConfig.oAuthRedirectUrl')"
:value="oAuthCallbackUrl"
:copy-button-text="$locale.baseText('credentialEdit.credentialConfig.clickToCopy')"
@ -204,6 +204,9 @@ export default defineComponent({
isOAuthType: {
type: Boolean,
},
allOAuth2BasePropertiesOverridden: {
type: Boolean,
},
isOAuthConnected: {
type: Boolean,
},

View File

@ -75,6 +75,7 @@
:parent-types="parentTypes"
:required-properties-filled="requiredPropertiesFilled"
:credential-permissions="credentialPermissions"
:all-o-auth2-base-properties-overridden="allOAuth2BasePropertiesOverridden"
:mode="mode"
:selected-credential="selectedCredential"
:show-auth-type-selector="requiredCredentials"
@ -427,6 +428,15 @@ export default defineComponent({
this.parentTypes.includes('oAuth1Api'))
);
},
allOAuth2BasePropertiesOverridden() {
if (this.credentialType?.__overwrittenProperties) {
return (
this.credentialType.__overwrittenProperties.includes('clientId') &&
this.credentialType.__overwrittenProperties.includes('clientSecret')
);
}
return false;
},
isOAuthConnected(): boolean {
return this.isOAuthType && !!this.credentialData.oauthTokenData;
},
@ -435,7 +445,7 @@ export default defineComponent({
return [];
}
return this.credentialType.properties.filter((propertyData: INodeProperties) => {
const properties = this.credentialType.properties.filter((propertyData: INodeProperties) => {
if (!this.displayCredentialParameter(propertyData)) {
return false;
}
@ -444,6 +454,17 @@ export default defineComponent({
!this.credentialType!.__overwrittenProperties.includes(propertyData.name)
);
});
/**
* If after all credentials overrides are applied only "notice"
* properties are left, do not return them. This will avoid
* showing notices that refer to a property that was overridden.
*/
if (properties.every((p) => p.type === 'notice')) {
return [];
}
return properties;
},
requiredPropertiesFilled(): boolean {
for (const property of this.credentialProperties) {