summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/user.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go
index 41fdf0b024..40afc48491 100644
--- a/models/user.go
+++ b/models/user.go
@@ -8,6 +8,7 @@ import (
"bytes"
"container/list"
"crypto/sha256"
+ "crypto/subtle"
"encoding/hex"
"errors"
"fmt"
@@ -368,7 +369,7 @@ func (u *User) EncodePasswd() {
func (u *User) ValidatePassword(passwd string) bool {
newUser := &User{Passwd: passwd, Salt: u.Salt}
newUser.EncodePasswd()
- return u.Passwd == newUser.Passwd
+ return subtle.ConstantTimeCompare([]byte(u.Passwd), []byte(newUser.Passwd)) == 1
}
// UploadAvatar saves custom avatar for user.