Browse Source

make sure setting code happen before callback in rest (#936)

Kevin Wan 3 years ago
parent
commit
9672298fa8
1 changed files with 3 additions and 2 deletions
  1. 3 2
      rest/handler/authhandler.go

+ 3 - 2
rest/handler/authhandler.go

@@ -112,11 +112,12 @@ func unauthorized(w http.ResponseWriter, r *http.Request, err error, callback Un
 	} else {
 		detailAuthLog(r, noDetailReason)
 	}
+
+	writer.WriteHeader(http.StatusUnauthorized)
+
 	if callback != nil {
 		callback(writer, r, err)
 	}
-
-	writer.WriteHeader(http.StatusUnauthorized)
 }
 
 type guardedResponseWriter struct {