fix indentation (tabs to 4 spaces) (oops)
This commit is contained in:
parent
fe4a788898
commit
23a02617f9
38 changed files with 447 additions and 447 deletions
|
@ -1,10 +1,10 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"arimelody-web/model"
|
||||
"strings"
|
||||
"arimelody-web/model"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func GetAllAccounts(db *sqlx.DB) ([]model.Account, error) {
|
||||
|
@ -112,24 +112,24 @@ func DeleteAccount(db *sqlx.DB, accountID string) error {
|
|||
}
|
||||
|
||||
func IncrementAccountFails(db *sqlx.DB, accountID string) (bool, error) {
|
||||
failAttempts := 0
|
||||
err := db.Get(&failAttempts, "UPDATE account SET fail_attempts = fail_attempts + 1 WHERE id=$1 RETURNING fail_attempts", accountID)
|
||||
if err != nil { return false, err }
|
||||
locked := false
|
||||
if failAttempts >= model.MAX_LOGIN_FAIL_ATTEMPTS {
|
||||
err = LockAccount(db, accountID)
|
||||
if err != nil { return false, err }
|
||||
locked = true
|
||||
}
|
||||
return locked, err
|
||||
failAttempts := 0
|
||||
err := db.Get(&failAttempts, "UPDATE account SET fail_attempts = fail_attempts + 1 WHERE id=$1 RETURNING fail_attempts", accountID)
|
||||
if err != nil { return false, err }
|
||||
locked := false
|
||||
if failAttempts >= model.MAX_LOGIN_FAIL_ATTEMPTS {
|
||||
err = LockAccount(db, accountID)
|
||||
if err != nil { return false, err }
|
||||
locked = true
|
||||
}
|
||||
return locked, err
|
||||
}
|
||||
|
||||
func LockAccount(db *sqlx.DB, accountID string) error {
|
||||
_, err := db.Exec("UPDATE account SET locked = true WHERE id=$1", accountID)
|
||||
return err
|
||||
_, err := db.Exec("UPDATE account SET locked = true WHERE id=$1", accountID)
|
||||
return err
|
||||
}
|
||||
|
||||
func UnlockAccount(db *sqlx.DB, accountID string) error {
|
||||
_, err := db.Exec("UPDATE account SET locked = false, fail_attempts = 0 WHERE id=$1", accountID)
|
||||
return err
|
||||
_, err := db.Exec("UPDATE account SET locked = false, fail_attempts = 0 WHERE id=$1", accountID)
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue