Merge pull request #4672 from overleaf/sk-validate-currency-param
Subscription: validate currency in query param GitOrigin-RevId: 0c9f841ba56b5ce85bbd2adeb3fb2d45d0ad753a
This commit is contained in:
@@ -17,6 +17,8 @@ const currencyMappings = {
|
||||
SE: 'SEK',
|
||||
}
|
||||
|
||||
const validCurrencyParams = Object.values(currencyMappings).concat(['EUR'])
|
||||
|
||||
// Countries which would likely prefer Euro's
|
||||
const EuroCountries = [
|
||||
'AT',
|
||||
@@ -48,6 +50,13 @@ const EuroCountries = [
|
||||
|
||||
_.each(EuroCountries, country => (currencyMappings[country] = 'EUR'))
|
||||
|
||||
function isValidCurrencyParam(currency) {
|
||||
if (!currency) {
|
||||
return false
|
||||
}
|
||||
return validCurrencyParams.includes(currency)
|
||||
}
|
||||
|
||||
function getDetails(ip, callback) {
|
||||
if (!ip) {
|
||||
return callback(new Error('no ip passed'))
|
||||
@@ -89,6 +98,7 @@ function getCurrencyCode(ip, callback) {
|
||||
module.exports = {
|
||||
getDetails,
|
||||
getCurrencyCode,
|
||||
isValidCurrencyParam,
|
||||
promises: {
|
||||
getDetails: promisify(getDetails),
|
||||
getCurrencyCode: promisifyMultiResult(getCurrencyCode, [
|
||||
|
||||
Reference in New Issue
Block a user