Check that sold bet is by auth'd user
This commit is contained in:
parent
c2f993ddf2
commit
f14bb63393
|
@ -50,6 +50,7 @@ export const sellBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
||||||
if (!betSnap.exists) return { status: 'error', message: 'Invalid bet' }
|
if (!betSnap.exists) return { status: 'error', message: 'Invalid bet' }
|
||||||
const bet = betSnap.data() as 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' }
|
if (bet.isSold) return { status: 'error', message: 'Bet already sold' }
|
||||||
|
|
||||||
const newBetDoc = firestore
|
const newBetDoc = firestore
|
||||||
|
|
Loading…
Reference in New Issue
Block a user