Distinguish empty key in password from absence of key.
This commit is contained in:
1 parent
4ad7c2f303
commit
695c379a6c
7 files changed
+46
-19
No files matched your search
+2
-1
@@ -408,10 +408,11 @@ func passwordHandler(w http.ResponseWriter, r *http.Request, g, user string) {
|
||||
}
|
||||
iterations := 4096
|
||||
key := pbkdf2.Key(body, salt, iterations, 32, sha256.New)
|
||||
encoded := hex.EncodeToString(key)
|
||||
pw := group.Password{
|
||||
Type: "pbkdf2",
|
||||
Hash: "sha-256",
|
||||
Key: hex.EncodeToString(key),
|
||||
Key: &encoded,
|
||||
Salt: hex.EncodeToString(salt),
|
||||
Iterations: iterations,
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ func TestApi(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Get user: %v", err)
|
||||
}
|
||||
if user.Password.Type != "" && user.Password.Key != "" {
|
||||
if user.Password.Type != "" && user.Password.Key != nil {
|
||||
t.Errorf("User not sanitised properly")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user