From 2bc2c935efb4819aa550128765d8bbfd5c13f788 Mon Sep 17 00:00:00 2001 From: Mikko Ahlroth Date: Tue, 13 Sep 2022 07:54:09 +0300 Subject: [PATCH] Fix token refresh error --- lib/geo_therminator/pump_api/auth/server.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/geo_therminator/pump_api/auth/server.ex b/lib/geo_therminator/pump_api/auth/server.ex index b89fdd8..cccb2ca 100644 --- a/lib/geo_therminator/pump_api/auth/server.ex +++ b/lib/geo_therminator/pump_api/auth/server.ex @@ -79,8 +79,12 @@ defmodule GeoTherminator.PumpAPI.Auth.Server do if diff < @token_check_diff do Logger.debug("Renewing auth token since #{diff} < #{@token_check_diff}") - user = Auth.API.auth(state.username, state.password) - {:noreply, %State{state | authed_user: user}} + + with {:ok, user} <- Auth.API.auth(state.username, state.password) do + {:noreply, %State{state | authed_user: user}} + else + _ -> {:noreply, state} + end else {:noreply, state} end