Skip to content

Commit 0383016

Browse files
authored
auth: remove getPassFromRequest function
1 parent c3d909a commit 0383016

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

auth.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ func Auth(update httprouter.Handle) httprouter.Handle {
2323
postData, err := decodePostData(r)
2424
if err != nil {
2525
log.WithFields(log.Fields{"error": "json_error", "string": err.Error()}).Error("Decode error")
26-
} else {
27-
getPassFromRequest(r, postData)
2826
}
2927
subdomain, err := getValidSubdomain(postData.Subdomain)
3028
if err != nil {
@@ -78,14 +76,15 @@ func decodePostData(r *http.Request) (ACMETxt, error) {
7876
if err != nil {
7977
return ACMETxt{}, err
8078
}
81-
return postData, nil
82-
}
8379

84-
func getPassFromRequest(r *http.Request, postData *ACMETxt) bool {
80+
key := r.Header.Get("X-Api-Key")
8581
if !validKey(postData.Password) {
86-
postData.Password = r.Header.Get("X-Api-Key")
82+
if validKey(key) {
83+
postData.Password = key
84+
}
8785
}
88-
return validKey(postData.Password)
86+
87+
return postData, nil
8988
}
9089

9190
func updateAllowedFromIP(r *http.Request, user ACMETxt) bool {

0 commit comments

Comments
 (0)