Skip to content

Commit

Permalink
bug: fix TestAuthenticateMiddleware_tryGetUserByApiKeyHeader_Success …
Browse files Browse the repository at this point in the history
…test

it ended up being because config isn't initialized during testing so a equals check will fail; simply adding a nil check fixed the issue
  • Loading branch information
taciturnaxolotl committed Sep 26, 2024
1 parent 525a799 commit ea8d447
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion middlewares/authenticate.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (m *AuthenticateMiddleware) tryGetUserByApiKeyHeader(r *http.Request) (*mod
var user *models.User
userKey := strings.TrimSpace(key)

if key == m.config.Security.AdminToken {
if m.config != nil && key == m.config.Security.AdminToken {
user, err = m.userSrvc.GetUserById(r.URL.Query().Get("user"))
} else {
user, err = m.userSrvc.GetUserByKey(userKey)
Expand Down

0 comments on commit ea8d447

Please sign in to comment.