[server] Fix deviceLimit tracker

This commit is contained in:
Neeraj Gupta 2024-08-03 16:13:26 +05:30 committed by Neeraj Gupta
parent 3392e39f7c
commit 29cf5b91a5

View File

@ -126,9 +126,7 @@ func (m *AccessTokenMiddleware) isDeviceLimitReached(ctx context.Context,
if network.IsCFWorkerIP(ip) {
return false, nil
}
if collectionSummary.DeviceLimit <= 0 { // no device limit was added
return false, nil
}
sharedID := collectionSummary.ID
hasAccessedInPast, err := m.PublicCollectionRepo.AccessedInPast(ctx, sharedID, ip, ua)
if err != nil {
@ -156,7 +154,7 @@ func (m *AccessTokenMiddleware) isDeviceLimitReached(ctx context.Context,
}
}
if count >= deviceLimit {
if deviceLimit > 0 && count >= deviceLimit {
return true, nil
}
err = m.PublicCollectionRepo.RecordAccessHistory(ctx, sharedID, ip, ua)