Skip to content

Commit

Permalink
fix(editor): Fix for oauth authorization (#4572)
Browse files Browse the repository at this point in the history
🐛 Fixing credentials response type check that prevented oauth authorization
  • Loading branch information
MiloradFilipovic authored Nov 10, 2022
1 parent 9b5db8d commit d06197d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ import {
ICredentialsDecrypted,
ICredentialType,
INode,
INodeCredentialTestResult,
INodeParameters,
INodeProperties,
INodeTypeDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { useRootStore } from '@/stores/n8nRootStore';
import { mapStores } from 'pinia';
import Vue from 'vue';
import mixins from 'vue-typed-mixins';
export default Vue.extend({
props: {
Expand Down
30 changes: 17 additions & 13 deletions packages/editor-ui/src/components/NodeCredentials.vue
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,23 @@ export default mixins(
this.credentialsStore.$subscribe((mutation, state) => {
// This data pro stores credential type that the component is currently interested in
const credentialType = this.subscribedToCredentialType;
const credentialsOfType = this.credentialsStore.allCredentialsByType[credentialType].sort((a, b) => (a.id < b.id ? -1 : 1));
if (credentialsOfType.length > 0) {
// If nothing has been selected previously, select the first one (newly added)
if (!this.selected[credentialType]) {
this.onCredentialSelected(credentialType, credentialsOfType[0].id);
} else {
// Else, check id currently selected cred has been updated
const newSelected = credentialsOfType.find(cred => cred.id === this.selected[credentialType].id);
// If it has changed, select it
if (newSelected && newSelected.name !== this.selected[credentialType].name) {
this.onCredentialSelected(credentialType, newSelected.id);
} else { // Else select the last cred with that type since selected has been deleted or a new one has been added
this.onCredentialSelected(credentialType, credentialsOfType[credentialsOfType.length - 1].id);
let credentialsOfType = this.credentialsStore.allCredentialsByType[credentialType];
if (credentialsOfType) {
credentialsOfType = credentialsOfType.sort((a, b) => (a.id < b.id ? -1 : 1));
if (credentialsOfType.length > 0) {
// If nothing has been selected previously, select the first one (newly added)
if (!this.selected[credentialType]) {
this.onCredentialSelected(credentialType, credentialsOfType[0].id);
} else {
// Else, check id currently selected cred has been updated
const newSelected = credentialsOfType.find(cred => cred.id === this.selected[credentialType].id);
// If it has changed, select it
if (newSelected && newSelected.name !== this.selected[credentialType].name) {
this.onCredentialSelected(credentialType, newSelected.id);
} else { // Else select the last cred with that type since selected has been deleted or a new one has been added
this.onCredentialSelected(credentialType, credentialsOfType[credentialsOfType.length - 1].id);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export function isNotNull<T>(value: T | null): value is T {
}

export function isValidCredentialResponse(value: unknown): value is ICredentialsResponse {
return typeof value === 'object' && value !== null && 'id' in value && 'createdAt' in value && 'updatedAt' in value;
return typeof value === 'object' && value !== null && 'id' in value;
}

0 comments on commit d06197d

Please sign in to comment.