create user: remove ip check

This commit is contained in:
mantikoros 2022-07-25 18:25:23 -07:00
parent 3107c8fe30
commit ec0e25e5ed

View File

@ -63,10 +63,7 @@ export const createuser = newEndpoint(opts, async (req, auth) => {
const deviceUsedBefore = const deviceUsedBefore =
!deviceToken || (await isPrivateUserWithDeviceToken(deviceToken)) !deviceToken || (await isPrivateUserWithDeviceToken(deviceToken))
const ipCount = req.ip ? await numberUsersWithIp(req.ip) : 0 const balance = deviceUsedBefore ? SUS_STARTING_BALANCE : STARTING_BALANCE
const balance =
deviceUsedBefore || ipCount > 2 ? SUS_STARTING_BALANCE : STARTING_BALANCE
const user: User = { const user: User = {
id: auth.uid, id: auth.uid,
@ -113,7 +110,7 @@ const isPrivateUserWithDeviceToken = async (deviceToken: string) => {
return !snap.empty return !snap.empty
} }
const numberUsersWithIp = async (ipAddress: string) => { export const numberUsersWithIp = async (ipAddress: string) => {
const snap = await firestore const snap = await firestore
.collection('private-users') .collection('private-users')
.where('initialIpAddress', '==', ipAddress) .where('initialIpAddress', '==', ipAddress)