Skip to content

Commit

Permalink
Extract function to refresh providers in Samly.Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
hodak committed Mar 15, 2019
1 parent e109fb1 commit 8b52db8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/samly/provider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule Samly.Provider do
store_opts = store_env[:opts] || []
State.init(store_provider, store_opts)

opts = Application.get_env(:samly, Samly.Provider, [])
opts = opts()

# must be done prior to loading the providers
idp_id_from =
Expand All @@ -56,6 +56,14 @@ defmodule Samly.Provider do
end

Application.put_env(:samly, :idp_id_from, idp_id_from)
refresh_providers()

{:ok, %{}}
end

@doc false
def refresh_providers do
opts = opts()

service_providers = Samly.SpData.load_providers(opts[:service_providers] || [])

Expand All @@ -64,7 +72,7 @@ defmodule Samly.Provider do

Application.put_env(:samly, :service_providers, service_providers)
Application.put_env(:samly, :identity_providers, identity_providers)

{:ok, %{}}
end

defp opts, do: Application.get_env(:samly, Samly.Provider, [])
end

0 comments on commit 8b52db8

Please sign in to comment.