Skip to content

Commit

Permalink
fix: crash when running admin cluster deploy command (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
pggb25 authored Jan 23, 2025
1 parent 81007a6 commit 79d460f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/auth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,15 @@ type QoveryClientApiRequest[T any] func(needToRefetchClient bool) (*T, *http.Res
// RetryQoveryClientApiRequestOnUnauthorized To be able to ask for re-auth when first attempt leads to unauthorized
func RetryQoveryClientApiRequestOnUnauthorized[T any](request QoveryClientApiRequest[T]) (*T, *http.Response, error) {
qoveryStruct, response, err := request(false)
if response.StatusCode == 401 {
if err != nil {
return qoveryStruct, response, fmt.Errorf("RetryQoveryClientApiRequestOnUnauthorized: initial request error: %w", err)
}

if response == nil {
return qoveryStruct, nil, fmt.Errorf("received nil response from request")
}

if response.StatusCode == http.StatusUnauthorized {
utils.Println("Needs to re-authenticate as the response is UNAUTHORIZED (401)")
DoRequestUserToAuthenticate(false)
qoveryStruct, response, err = request(true)
Expand Down

0 comments on commit 79d460f

Please sign in to comment.