Skip to content

Commit

Permalink
Update login attempt =0 on success
Browse files Browse the repository at this point in the history
  • Loading branch information
rupinr committed Nov 3, 2024
1 parent 49295fe commit b015aec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 4 additions & 1 deletion auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ func ValidateJWT(tokenString string) (*DecodedUser, error) {
user.Valid = true
user.Email = claims.Email
user.ID = claims.ID
resetLoginAttemptCounter(user.ID)

if !user.Admin {
resetLoginAttemptCounter(user.ID)
}
} else {
logger.Log.Debug("Invalid token.")
}
Expand Down
5 changes: 1 addition & 4 deletions repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ func MarkUserDeleted(email string) {
}

func ResetLoginCounter(id uint) {
user := entity.User{}
db().Find(&user, id)
user.LoginAttemptCount = 0
db().Updates(&user)
db().Model(&entity.User{}).Where("id = ?", id).Updates(map[string]interface{}{"LoginAttemptCount": 0})
}

func GetUser(userData dto.User) entity.User {
Expand Down

0 comments on commit b015aec

Please sign in to comment.