summaryrefslogtreecommitdiff
path: root/lib/lsg_web/context_plug.ex
diff options
context:
space:
mode:
authorhref <href@random.sh>2021-09-07 05:28:02 +0200
committerhref <href@random.sh>2021-09-07 05:28:02 +0200
commitcf7b21afa87ca5202bd626d26a60adab1e9131a1 (patch)
tree245cbb332e9ab63a2b84e4168e0ce750dc1e7ae9 /lib/lsg_web/context_plug.ex
parentuser_track: fix find_by_account/2 (diff)
web: openid & various fixes
Diffstat (limited to 'lib/lsg_web/context_plug.ex')
-rw-r--r--lib/lsg_web/context_plug.ex12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/lsg_web/context_plug.ex b/lib/lsg_web/context_plug.ex
index 7896ace..29eab28 100644
--- a/lib/lsg_web/context_plug.ex
+++ b/lib/lsg_web/context_plug.ex
@@ -6,9 +6,16 @@ defmodule LSGWeb.ContextPlug do
opts || []
end
+ def get_account(conn) do
+ cond do
+ get_session(conn, :account) -> get_session(conn, :account)
+ get_session(conn, :oidc_id) -> if account = IRC.Account.find_meta_account("identity-id", get_session(conn, :oidc_id)), do: account.id
+ end
+ end
+
def call(conn, opts) do
account = with \
- {:account, account_id} when is_binary(account_id) <- {:account, get_session(conn, :account)},
+ {:account, account_id} when is_binary(account_id) <- {:account, get_account(conn)},
{:account, account} when not is_nil(account) <- {:account, IRC.Account.get(account_id)}
do
account
@@ -19,6 +26,8 @@ defmodule LSGWeb.ContextPlug do
network = Map.get(conn.params, "network")
network = if network == "-", do: nil, else: network
+ oidc_account = IRC.Account.find_meta_account("identity-id", get_session(conn, :oidc_id))
+
conns = IRC.Connection.get_network(network)
chan = if c = Map.get(conn.params, "chan") do
LSGWeb.reformat_chan(c)
@@ -74,6 +83,7 @@ defmodule LSGWeb.ContextPlug do
|> assign(:chan, chan)
|> assign(:bot, bot)
|> assign(:account, account)
+ |> assign(:oidc_account, oidc_account)
|> assign(:memberships, memberships)
end
end