Skip to content

Open source personal finance application

fix(security): remove unauthenticated refreshRates public action

Ilya Komichevb73d13f3c1a7
diff --git a/app/components/currencies/useCurrenciesStore.ts b/app/components/currencies/useCurrenciesStore.ts
index fbc2a8a6..b581bf6a 100644
--- a/app/components/currencies/useCurrenciesStore.ts
+++ b/app/components/currencies/useCurrenciesStore.ts
@@ -23,16 +23,8 @@ export const useCurrenciesStore = defineStore('currencies', () => {
// Get latest rates from Convex
const latestRates = await client.query(api.rates.getLatest, {})
- if (latestRates?.rates) {
+ if (latestRates?.rates)
setRates(latestRates.rates as Rates)
- }
- else {
- // If no rates exist, try to refresh them via action
- await client.action(api.rates.refreshRates, {})
- const freshRates = await client.query(api.rates.getLatest, {})
- if (freshRates?.rates)
- setRates(freshRates.rates as Rates)
- }
}
catch (e) {
logger.error('init failed', e)
diff --git a/convex/rates.ts b/convex/rates.ts
index 9b144cad..bb0e17a0 100644
--- a/convex/rates.ts
+++ b/convex/rates.ts
@@ -1,7 +1,7 @@
import { v } from 'convex/values'
import { internal } from './_generated/api'
-import { action, internalAction, internalMutation, query } from './_generated/server'
+import { internalAction, internalMutation, query } from './_generated/server'
const appId = process.env.OPENEXCHANGERATES_APP_ID
@@ -36,13 +36,6 @@ export const saveRates = internalMutation({
},
})
-export const refreshRates = action({
- args: {},
- handler: async (ctx) => {
- await ctx.runAction(internal.rates.fetchAndSaveRates, {})
- },
-})
-
export const fetchAndSaveRates = internalAction({
args: {},
handler: async (ctx) => {