0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Fixed settings validation error not distinguishing between publishable/secret keys

no issue

- when saving Stripe keys with `stripeDirect: true` config, if either key didn't match the key format the returned validation error always contained `stripe_secret_key`
- updated to output `stripe_publishable_key` if it was the publishable key that was invalid
This commit is contained in:
Kevin Ansfield 2021-02-03 16:42:51 +00:00
parent 7d4596adf6
commit 7195a904ba

View file

@ -384,11 +384,11 @@ Settings = ghostBookshelf.Model.extend({
return;
}
const secretKeyRegex = /pk_(?:test|live)_[\da-zA-Z]{1,247}$/;
const publishableKeyRegex = /pk_(?:test|live)_[\da-zA-Z]{1,247}$/;
if (!secretKeyRegex.test(value)) {
if (!publishableKeyRegex.test(value)) {
throw new errors.ValidationError({
message: `stripe_secret_key did not match ${secretKeyRegex}`
message: `stripe_publishable_key did not match ${publishableKeyRegex}`
});
}
},
@ -412,11 +412,11 @@ Settings = ghostBookshelf.Model.extend({
return;
}
const secretKeyRegex = /pk_(?:test|live)_[\da-zA-Z]{1,247}$/;
const publishableKeyRegex = /pk_(?:test|live)_[\da-zA-Z]{1,247}$/;
if (!secretKeyRegex.test(value)) {
if (!publishableKeyRegex.test(value)) {
throw new errors.ValidationError({
message: `stripe_secret_key did not match ${secretKeyRegex}`
message: `stripe_publishable_key did not match ${publishableKeyRegex}`
});
}
}