Skip to content

Commit c61ee72

Browse files
committed
Improve nil logic in refreshToken
1 parent c957d32 commit c61ee72

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

garden-app/pkg/weather/netatmo/client.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,12 @@ func (c *Client) setDeviceIDs() error {
197197
}
198198

199199
func (c *Client) refreshToken() error {
200-
if c.Authentication == nil {
200+
if c.Config.Authentication == nil {
201201
return errors.New("authentication is required but not configured")
202202
}
203203

204-
expiry := clock.Now().AddDate(0, 0, -1)
205-
if c.Config.Authentication != nil {
206-
// It's safe to ignore the time.Parse error because knowing the expiration is an optional early exit
207-
expiry, _ = time.Parse(time.RFC3339Nano, c.Config.Authentication.ExpirationDate)
208-
}
204+
// It's safe to ignore the time.Parse error because knowing the expiration is an optional early exit
205+
expiry, _ := time.Parse(time.RFC3339Nano, c.Config.Authentication.ExpirationDate)
209206

210207
// Exit early if token is not expired
211208
if clock.Now().Before(expiry) {

0 commit comments

Comments
 (0)