Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions web/webui/two_factor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,29 @@ func UserTwoFactorVerify(c *gin.Context) {
return
}
if !tokenIsValid {
// TODO: increment failed login attempt count
// User model needs FailedLogins and LockoutUntil.
// Then we need logic to enforce the lockout.
msg := "Backup code is incorrect. Try again."
if method == constants.TwoFactorSMS {
msg = "One-time password is incorrect. Try again."
}

// TODO: increment failed login attempt count
// User model needs FailedLogins and LockoutUntil.
// Then we need logic to enforce the lockout.

// user.FailedLogins++
// if user.FailedLogins == constants.MaxFailedLoginsBeforeCooldown - 1 {
// msg = "Last attempt before cooldown period is enforced."
// } else if user.FailedLogins == constants.MaxFailedLoginsBeforeCooldown {
// msg = "Too many failed logins. Cooldown is enforced."
// user.CooldownUntil = now + constants.AccountCooldownTimePeriod
// } else if user.FailedLogins == constants.MaxFailedLoginsBeforeLockout - 1 {
// msg = "Last attempt before account locked."
// } else if user.FailedLogins == constants.MaxFailedLoginsBeforeLockout {
// msg = "Too many failed logins. Account has been locked for your security. Contact help@aptrust for help."
// user.IsLockout = true
// }
// user.Save()

req.TemplateData["flash"] = msg
c.HTML(http.StatusBadRequest, "users/enter_auth_token.html", req.TemplateData)
} else {
Expand Down