-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I try to update some data within the session when a certain constellation has occurred. As soon as I use the function PhoenixLiveSession.put_session I get the following error:
Request: GET /dashboard
** (exit) an exception was raised:
** (FunctionClauseError) no function clause matching in Keyword.fetch!/2
(elixir 1.12.3) lib/keyword.ex:417: Keyword.fetch!(nil, :table)
(phoenix_live_session 0.1.3) lib/phoenix_live_session.ex:159: PhoenixLiveSession.put_in/4
(phoenix_live_session 0.1.3) lib/phoenix_live_session.ex:261: PhoenixLiveSession.put_session/3
My mount looks like this:
@impl true
def mount(params, %{"locale" => locale} = session, socket) do
Gettext.put_locale(ExampleApp.Gettext, locale)
socket =
socket
|> PhoenixLiveSession.maybe_subscribe(session)
|> MountHelpers.assign_defaults(params, session, {@privileges, :read})
|> assign_breadcrumbs()
|> MountHelpers.assign_page_title()
{:ok, socket, temporary_assigns: [
user_groups: []
]
}
end
And i am using the handle info callback as described:
@impl true
def handle_info({:live_session_updated, session}, socket) do
{:noreply, MountHelpers.put_session_assigns(socket, session)}
end
My put session assigns function looks like this:
def put_session_assigns(socket, session) do
initial_tokens =
Map.take(session, ["__idx_token", "__idx_refresh_token", "__idx_id_token"])
tokens =
IdxClient.ensure_authenticated(:admin, initial_tokens)
socket
|> PhoenixLiveSession.put_session("__idx_token", tokens["__idx_token"])
|> PhoenixLiveSession.put_session("__idx_refresh_token", tokens["__idx_refresh_token"])
|> PhoenixLiveSession.put_session("__idx_id_token", tokens["__idx_id_token"])
|> assign(:tokens, tokens)
end
Am i doing something wrong?
Metadata
Metadata
Assignees
Labels
No labels