mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
fix(core): OAuth2 scopes does not save
This commit is contained in:
parent
67aad63343
commit
7aefed46dc
|
@ -78,12 +78,14 @@ oauth2CredentialController.get(
|
|||
throw new ResponseHelper.InternalServerError((error as Error).message);
|
||||
}
|
||||
|
||||
const credentialType = (credential as unknown as ICredentialsEncrypted).type;
|
||||
|
||||
const mode: WorkflowExecuteMode = 'internal';
|
||||
const timezone = config.getEnv('generic.timezone');
|
||||
const credentialsHelper = new CredentialsHelper(encryptionKey);
|
||||
const decryptedDataOriginal = await credentialsHelper.getDecrypted(
|
||||
credential as INodeCredentialsDetails,
|
||||
(credential as unknown as ICredentialsEncrypted).type,
|
||||
credentialType,
|
||||
mode,
|
||||
timezone,
|
||||
true,
|
||||
|
@ -91,13 +93,17 @@ oauth2CredentialController.get(
|
|||
|
||||
// At some point in the past we saved hidden scopes to credentials (but shouldn't)
|
||||
// Delete scope before applying defaults to make sure new scopes are present on reconnect
|
||||
if (decryptedDataOriginal?.scope) {
|
||||
if (
|
||||
decryptedDataOriginal?.scope &&
|
||||
credentialType.includes('OAuth2') &&
|
||||
!['oAuth2Api'].includes(credentialType)
|
||||
) {
|
||||
delete decryptedDataOriginal.scope;
|
||||
}
|
||||
|
||||
const oauthCredentials = credentialsHelper.applyDefaultsAndOverwrites(
|
||||
decryptedDataOriginal,
|
||||
(credential as unknown as ICredentialsEncrypted).type,
|
||||
credentialType,
|
||||
mode,
|
||||
timezone,
|
||||
);
|
||||
|
@ -128,7 +134,7 @@ oauth2CredentialController.get(
|
|||
// Encrypt the data
|
||||
const credentials = new Credentials(
|
||||
credential as INodeCredentialsDetails,
|
||||
(credential as unknown as ICredentialsEncrypted).type,
|
||||
credentialType,
|
||||
(credential as unknown as ICredentialsEncrypted).nodesAccess,
|
||||
);
|
||||
decryptedDataOriginal.csrfSecret = csrfSecret;
|
||||
|
|
Loading…
Reference in a new issue