🐛 Bug fixes

This commit is contained in:
2024-06-26 15:17:10 +08:00
parent 6667bff188
commit 8044a1e5f2
7 changed files with 30 additions and 25 deletions

View File

@ -12,22 +12,13 @@ import (
)
func DetectRisk(user models.Account, ip, ua string) bool {
var availableFactor int64
if err := database.C.
Where(models.AuthFactor{AccountID: user.ID}).
Where("type != ?", models.PasswordAuthFactor).
Model(models.AuthFactor{}).
Where(&availableFactor); err != nil || availableFactor <= 0 {
return false
}
var secureFactor int64
var clue int64
if err := database.C.
Where(models.AuthTicket{AccountID: user.ID, IpAddress: ip}).
Where("available_at IS NOT NULL").
Model(models.AuthTicket{}).
Count(&secureFactor).Error; err == nil {
if secureFactor >= 1 {
Count(&clue).Error; err == nil {
if clue >= 1 {
return false
}
}