Skip to content

Commit

Permalink
make sure the first account is issued
Browse files Browse the repository at this point in the history
  • Loading branch information
kayra1 committed Jul 11, 2024
1 parent f78aff3 commit b533462
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"net/http"
"regexp"
"strconv"
"strings"

"github.com/canonical/gocert/internal/metrics"
Expand Down Expand Up @@ -108,8 +109,10 @@ func authMiddleware(ctx *middlewareContext) middleware {
return
}
if r.Method == "POST" && strings.HasSuffix(r.URL.Path, "accounts") && !ctx.firstAccountIssued {
ctx.firstAccountIssued = true
next.ServeHTTP(w, r)
if strings.HasPrefix(strconv.Itoa(ctx.responseStatusCode), "2") {
ctx.firstAccountIssued = true
}
return
}
authHeader := r.Header.Get("Authorization")
Expand Down

0 comments on commit b533462

Please sign in to comment.