fix unmarshal panic
This commit is contained in:
parent
dff505037f
commit
0d4f34f6d5
|
@ -33,7 +33,7 @@ func (f *Fail2Ban) FailedAttempt(ip string) {
|
|||
}
|
||||
|
||||
client.FailedAttempts++
|
||||
if client.FailedAttempts >= 3 {
|
||||
if client.FailedAttempts >= 2 {
|
||||
client.BlockedUntil = time.Now().Add(10 * time.Minute)
|
||||
client.FailedAttempts = 0
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
)
|
||||
|
||||
type account struct {
|
||||
salt string `prosody:"salt"`
|
||||
storedKey string `prosody:"stored_key"`
|
||||
iterationCount int `prosody:"iteration_count"`
|
||||
Salt string `prosody:"salt"`
|
||||
StoredKey string `prosody:"stored_key"`
|
||||
IterationCount int `prosody:"iteration_count"`
|
||||
}
|
||||
|
||||
func (acc *account) unmarshal(data map[string]interface{}) {
|
||||
|
|
|
@ -18,13 +18,13 @@ func (p *Prosody) ChangePassword(user string, currentPwd string, newPwd string)
|
|||
return fmt.Errorf("p.loadAccount %w", err)
|
||||
}
|
||||
|
||||
storedKey, err := hashPassword(currentPwd, acc.salt, acc.iterationCount)
|
||||
storedKey, err := hashPassword(currentPwd, acc.Salt, acc.IterationCount)
|
||||
if err != nil {
|
||||
return fmt.Errorf("hashPassword: %w", err)
|
||||
}
|
||||
|
||||
// Compare the hashes
|
||||
if storedKey != acc.storedKey {
|
||||
if storedKey != acc.StoredKey {
|
||||
return errors.New("password is incorrect")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue