Skip to content

Commit

Permalink
allow valid auth with empty sid
Browse files Browse the repository at this point in the history
  • Loading branch information
lovelaze committed Oct 8, 2024
1 parent a2a8e15 commit 9115ef0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
12 changes: 4 additions & 8 deletions internal/pihole/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ func (a *auth) verify() error {
return errors.New("invalid sid found")
}

if a.sid == "" {
return errors.New("no sid found")
}

if a.validity <= 0 {
return errors.New("expired sid found")
}

return nil
}

Expand Down Expand Up @@ -121,6 +113,10 @@ func (client *client) DeleteSession() error {
return client.wrapError(err, nil)
}

if client.auth.sid == "" {
return nil
}

req, err := http.NewRequest("DELETE", client.ApiPath("auth"), nil)
if err != nil {
return client.wrapError(err, req)
Expand Down
7 changes: 0 additions & 7 deletions internal/pihole/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,7 @@ func Test_auth_verify(t *testing.T) {
assert.Error(t, a.verify())

a.valid = true
assert.Error(t, a.verify())

a.sid = "sid123"
assert.Error(t, a.verify())

a.validity = 1
assert.NoError(t, a.verify())

}

func createClient(container tc.Container) Client {
Expand Down

0 comments on commit 9115ef0

Please sign in to comment.