Check that sold bet is by auth'd user

This commit is contained in:
James Grugett 2022-06-01 18:30:40 -05:00
parent c2f993ddf2
commit f14bb63393

View File

@ -50,6 +50,7 @@ export const sellBet = functions.runWith({ minInstances: 1 }).https.onCall(
if (!betSnap.exists) return { status: 'error', message: 'Invalid bet' }
const bet = betSnap.data() as Bet
if (userId !== bet.userId) return { status: 'error', message: 'Not authorized' }
if (bet.isSold) return { status: 'error', message: 'Bet already sold' }
const newBetDoc = firestore