Skip to content

Commit 5820cce

Browse files
committed
Ban by device id for nand players and csnum for all
1 parent 50138d6 commit 5820cce

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

database/login.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818
WITH RECURSIVE device_tree AS (
1919
SELECT unnest(ng_device_id) AS device_id
2020
FROM users
21-
WHERE ng_device_id && $1
21+
WHERE ng_device_id && $2
2222
UNION
2323
SELECT unnest(ng_device_id)
2424
FROM users
@@ -29,10 +29,13 @@ const (
2929
SELECT has_ban, ban_tos, ng_device_id, ban_reason
3030
FROM users
3131
WHERE has_ban = true
32-
AND (profile_id = $2
33-
OR last_ip_address = $3
34-
OR ($4 != '' AND last_ip_address = $4))
35-
AND (ban_expires IS NULL OR ban_expires > $5)
32+
AND (profile_id = $3
33+
OR (ng_device_id && (SELECT * FROM known_ng_device_ids)
34+
AND $1 != 67349608)
35+
OR last_ip_address = $4
36+
OR ($4 != '' AND last_ip_address = $5)
37+
OR $7 && csnum)
38+
AND (ban_expires IS NULL OR ban_expires > $6)
3639
ORDER BY ban_tos DESC LIMIT 1`
3740
)
3841

@@ -226,7 +229,7 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb
226229
var banReason string
227230

228231
timeNow := time.Now()
229-
err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason)
232+
err = pool.QueryRow(ctx, SearchUserBan, ngDeviceId, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow, user.Csnum).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason)
230233

231234
if err != nil {
232235
if err != pgx.ErrNoRows {

0 commit comments

Comments
 (0)