✨ Improve risk calculation
This commit is contained in:
parent
930607f0f2
commit
f78ccd8d9d
@ -2,7 +2,6 @@ package security
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
"code.smartsheep.studio/hydrogen/passport/pkg/database"
|
||||||
@ -36,7 +35,7 @@ func NewChallenge(account models.Account, factors []models.AuthFactor, ip, ua st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Thinking of the requirements factors
|
// Thinking of the requirements factors
|
||||||
requirements := int(math.Max(float64(len(factors)), math.Min(float64(risk), 1)))
|
requirements := lo.Clamp(risk, 1, len(factors))
|
||||||
|
|
||||||
challenge = models.AuthChallenge{
|
challenge = models.AuthChallenge{
|
||||||
IpAddress: ip,
|
IpAddress: ip,
|
||||||
|
Loading…
Reference in New Issue
Block a user