From 2fcd68a231a4c260f365089448e75f66d1631d18 Mon Sep 17 00:00:00 2001 From: "Hongbin.Yuan" Date: Thu, 23 May 2024 20:33:58 +0200 Subject: [PATCH] print tg auth_date --- .../dl/officialsite/bot/util/TelegramVerifyValidator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/dl/officialsite/bot/util/TelegramVerifyValidator.java b/src/main/java/com/dl/officialsite/bot/util/TelegramVerifyValidator.java index ce47cd24..60addd17 100644 --- a/src/main/java/com/dl/officialsite/bot/util/TelegramVerifyValidator.java +++ b/src/main/java/com/dl/officialsite/bot/util/TelegramVerifyValidator.java @@ -29,8 +29,9 @@ public static boolean verifyTelegramParameter(Map params, String try { long authDate = Long.parseLong(params.get("auth_date")); long now = Instant.now().getEpochSecond(); - if (authDate >= now || (now - authDate) > AUTH_DATE_RANGE_MINUTE * 60) { - log.error("The auth date of telegram request is before {} minutes ago.", AUTH_DATE_RANGE_MINUTE); + if (Math.abs(now - authDate) > AUTH_DATE_RANGE_MINUTE * 60) { + log.error("The auth date {} of telegram request is before {} minutes ago compare to now {}.", authDate, + AUTH_DATE_RANGE_MINUTE, now); return false; } SecretKeySpec sk = new SecretKeySpec(