expiration checkj
parent
2983531a8c
commit
4c1a12af4c
|
@ -100,30 +100,36 @@ func IncomingMessagesHandler() {
|
||||||
replyMessage = "The code you entered is invalid. Please check the code and try again."
|
replyMessage = "The code you entered is invalid. Please check the code and try again."
|
||||||
} else {
|
} else {
|
||||||
// code found in cache
|
// 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)
|
||||||
|
|
||||||
var foundVerifiedUser structs.VerifiedUser
|
replyMessage = "The code you entered is expired. Please check the code and try again."
|
||||||
|
|
||||||
database.DB.Where("chat_id = ?", update.Message.From.ID).First(&foundVerifiedUser)
|
|
||||||
|
|
||||||
if foundVerifiedUser.UserId != "" {
|
|
||||||
// user already verified
|
|
||||||
|
|
||||||
replyMessage = "You have already verified your account. You will continue to receive notifications. Type /unsubscribe to stop receiving notifications."
|
|
||||||
|
|
||||||
logger.AddSystemLog(rslogger.LogTypeWarning, "User: %s %s has tried to verify his account with code %s, but has already verified his account", update.Message.From.FirstName, update.Message.From.LastName, code)
|
|
||||||
} else {
|
} else {
|
||||||
// user not verified
|
var foundVerifiedUser structs.VerifiedUser
|
||||||
|
|
||||||
replyMessage = "You have successfully verified your account. You will now receive notifications. Type /unsubscribe to stop receiving notifications."
|
database.DB.Where("chat_id = ?", update.Message.From.ID).First(&foundVerifiedUser)
|
||||||
|
|
||||||
database.DB.Create(&structs.VerifiedUser{
|
if foundVerifiedUser.UserId != "" {
|
||||||
UserId: tempVerify.UserId,
|
// user already verified
|
||||||
ChatId: update.Message.From.ID,
|
|
||||||
Filter: utils.NotificationTypeError,
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
})
|
|
||||||
|
|
||||||
logger.AddSystemLog(rslogger.LogTypeInfo, "User: %s %s has subscribed to receive notifications", update.Message.From.FirstName, update.Message.From.LastName)
|
replyMessage = "You have already verified your account. You will continue to receive notifications. Type /unsubscribe to stop receiving notifications."
|
||||||
|
|
||||||
|
logger.AddSystemLog(rslogger.LogTypeWarning, "User: %s %s has tried to verify his account with code %s, but has already verified his account", update.Message.From.FirstName, update.Message.From.LastName, code)
|
||||||
|
} else {
|
||||||
|
// user not verified
|
||||||
|
|
||||||
|
replyMessage = "You have successfully verified your account. You will now receive notifications. Type /unsubscribe to stop receiving notifications."
|
||||||
|
|
||||||
|
database.DB.Create(&structs.VerifiedUser{
|
||||||
|
UserId: tempVerify.UserId,
|
||||||
|
ChatId: update.Message.From.ID,
|
||||||
|
Filter: utils.NotificationTypeError,
|
||||||
|
CreatedAt: time.Now(),
|
||||||
|
})
|
||||||
|
|
||||||
|
logger.AddSystemLog(rslogger.LogTypeInfo, "User: %s %s has subscribed to receive notifications", update.Message.From.FirstName, update.Message.From.LastName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.RemoveTempVerifyCode(tempVerify.UserId)
|
cache.RemoveTempVerifyCode(tempVerify.UserId)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VerifyCodeLength = 6
|
VerifyCodeLength = 6
|
||||||
TempVerifyCodeExpirationTime = 5 * time.Minute
|
TempVerifyCodeExpirationTime = 10 * time.Minute // also change on admin dashboard web
|
||||||
|
|
||||||
NotificationIconSuccess = "🟢"
|
NotificationIconSuccess = "🟢"
|
||||||
NotificationSymbolInfo = "🔵"
|
NotificationSymbolInfo = "🔵"
|
||||||
|
|
Loading…
Reference in New Issue