ignore validation for oauth, service acct cred googleoauth

This commit is contained in:
Nancy Butler 2021-04-26 11:41:27 -07:00
parent 9f62d40f40
commit 9f106198c4
3 changed files with 6 additions and 33 deletions

View File

@ -59,25 +59,6 @@ export default {
};
}
},
created() {
this.registerBeforeHook(this.addCreds, 'willsave');
},
methods: {
// re-add credentials when adding allowed users/groups to model
addCreds() {
if (this.model.enabled) {
const { oauthCredential, serviceAccountCredential } = this.originalValue;
if (!this.model.oauthCredential) {
this.model.oauthCredential = oauthCredential;
}
if (!this.model.serviceAccountCredential) {
this.model.serviceAccountCredential = serviceAccountCredential;
}
}
}
}
};
</script>

View File

@ -157,7 +157,11 @@ export default {
addObject(this.model.allowedPrincipalIds, this.me.id);
}
}
await this.model.save();
if (wasEnabled && configType === 'oauth') {
await this.model.save({ ignoreFields: ['oauthCredential', 'serviceAccountCredential'] });
} else {
await this.model.save();
}
await this.reloadModel();
this.isEnabling = false;
this.editConfig = false;
@ -235,18 +239,6 @@ export default {
set(this.model, 'disabledStatusBitmask', 0);
}
break;
case 'oauth':
if (this.model.id === 'googleoauth') {
const { oauthCredential, serviceAccountCredential } = this.originalValue;
if (!this.model.oauthCredential) {
set(this.model, 'oauthCredential', oauthCredential);
}
if (!this.model.serviceAccountCredential) {
set(this.model, 'serviceAccountCredential', serviceAccountCredential);
}
}
break;
default:
break;
}

View File

@ -817,7 +817,7 @@ export default {
delete this.__rehydrate;
const forNew = !this.id;
const errors = await this.validationErrors(this);
const errors = await this.validationErrors(this, opt.ignoreFields);
if (!isEmpty(errors)) {
return Promise.reject(errors);