expiration checkj

main
alex 2023-10-21 18:39:10 +02:00
parent 2983531a8c
commit 4c1a12af4c
2 changed files with 26 additions and 20 deletions

View File

@ -100,7 +100,12 @@ func IncomingMessagesHandler() {
replyMessage = "The code you entered is invalid. Please check the code and try again."
} else {
// code found in cache
// check if code is expired
if tempVerify.ExpiredAt.Before(time.Now()) {
logger.AddSystemLog(rslogger.LogTypeWarning, "Received code which was expired from user: %s %s. Message: %s", update.Message.From.FirstName, update.Message.From.LastName, code)
replyMessage = "The code you entered is expired. Please check the code and try again."
} else {
var foundVerifiedUser structs.VerifiedUser
database.DB.Where("chat_id = ?", update.Message.From.ID).First(&foundVerifiedUser)
@ -125,6 +130,7 @@ func IncomingMessagesHandler() {
logger.AddSystemLog(rslogger.LogTypeInfo, "User: %s %s has subscribed to receive notifications", update.Message.From.FirstName, update.Message.From.LastName)
}
}
cache.RemoveTempVerifyCode(tempVerify.UserId)
}

View File

@ -6,7 +6,7 @@ import (
const (
VerifyCodeLength = 6
TempVerifyCodeExpirationTime = 5 * time.Minute
TempVerifyCodeExpirationTime = 10 * time.Minute // also change on admin dashboard web
NotificationIconSuccess = "🟢"
NotificationSymbolInfo = "🔵"