diff --git a/lib/farmbot/bootstrap/auth_task.ex b/lib/farmbot/bootstrap/auth_task.ex index 5633ed34..f064c581 100644 --- a/lib/farmbot/bootstrap/auth_task.ex +++ b/lib/farmbot/bootstrap/auth_task.ex @@ -44,6 +44,7 @@ defmodule Farmbot.Bootstrap.AuthTask do if get_config_value(:bool, "settings", "auto_sync") do Farmbot.Repo.flip() end + Farmbot.System.Registry.dispatch :authorization, :new_token restart_transports() refresh_timer(self()) {:error, err} -> diff --git a/test/farmbot/bootstrap/authorization_test.exs b/test/farmbot/bootstrap/authorization_test.exs index d944c916..a254ee32 100644 --- a/test/farmbot/bootstrap/authorization_test.exs +++ b/test/farmbot/bootstrap/authorization_test.exs @@ -40,9 +40,12 @@ defmodule Farmbot.Bootstrap.AuthorizationTest do end test "internet off and back on refreshes token" do + Farmbot.System.Registry.subscribe(self()) old = Farmbot.System.ConfigStorage.get_config_value(:string, "authorization", "token") send AuthTask, {Farmbot.System.Registry, {:network, :dns_up}} - Process.sleep(100) + + assert_receive {Farmbot.System.Registry, {:authorization, :new_token}} + new = Farmbot.System.ConfigStorage.get_config_value(:string, "authorization", "token") assert old != new end