Migrate GORM to generics API, simplify user-domain relationship, refactor models
This commit is contained in:
parent
19ce2224b8
commit
560b40503a
9 changed files with 192 additions and 117 deletions
|
|
@ -176,7 +176,7 @@ func isLockedOut(ip, identifier string, database *db.DB) bool {
|
|||
}
|
||||
|
||||
database.Model(&db.ImcLoginAttempt{}).
|
||||
Where("email = ? AND attempted_at > ? AND successful = false", identifier, cutoff).
|
||||
Where("username = ? AND attempted_at > ? AND successful = false", identifier, cutoff).
|
||||
Count(&count)
|
||||
|
||||
return count >= MaxLoginAttempts
|
||||
|
|
@ -184,7 +184,7 @@ func isLockedOut(ip, identifier string, database *db.DB) bool {
|
|||
|
||||
func recordFailedAttempt(identifier, ip string, database *db.DB) {
|
||||
database.Create(&db.ImcLoginAttempt{
|
||||
Email: identifier,
|
||||
Username: identifier,
|
||||
IPAddress: ip,
|
||||
Successful: false,
|
||||
})
|
||||
|
|
@ -192,7 +192,7 @@ func recordFailedAttempt(identifier, ip string, database *db.DB) {
|
|||
|
||||
func clearFailedAttempts(identifier, ip string, database *db.DB) {
|
||||
database.Model(&db.ImcLoginAttempt{}).
|
||||
Where("email = ? OR ip_address = ?", identifier, ip).
|
||||
Where("username = ? OR ip_address = ?", identifier, ip).
|
||||
Update("successful", true)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue