2020-06-27 17:12:45 +00:00
|
|
|
defmodule Mobilizon.Web.AuthView do
|
|
|
|
@moduledoc """
|
|
|
|
View for the auth routes
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Mobilizon.Web, :view
|
|
|
|
alias Mobilizon.Service.Metadata.Instance
|
2022-09-21 06:32:42 +00:00
|
|
|
alias Mobilizon.Web.PageView
|
2020-06-27 17:12:45 +00:00
|
|
|
alias Phoenix.HTML.Tag
|
|
|
|
|
2021-09-27 07:41:36 +00:00
|
|
|
@spec render(String.t(), map()) :: String.t() | Plug.Conn.t()
|
2022-07-12 08:55:28 +00:00
|
|
|
def render(
|
|
|
|
"callback.html",
|
|
|
|
%{
|
|
|
|
conn: _conn,
|
|
|
|
access_token: access_token,
|
|
|
|
refresh_token: refresh_token,
|
|
|
|
user: %{
|
|
|
|
id: user_id,
|
|
|
|
email: user_email,
|
|
|
|
role: user_role,
|
|
|
|
default_actor_id: user_actor_id
|
|
|
|
}
|
|
|
|
} = assigns
|
|
|
|
) do
|
2020-06-27 17:12:45 +00:00
|
|
|
info_tags = [
|
|
|
|
Tag.tag(:meta, name: "auth-access-token", content: access_token),
|
|
|
|
Tag.tag(:meta, name: "auth-refresh-token", content: refresh_token),
|
|
|
|
Tag.tag(:meta, name: "auth-user-id", content: user_id),
|
|
|
|
Tag.tag(:meta, name: "auth-user-email", content: user_email),
|
2022-04-28 09:43:05 +00:00
|
|
|
Tag.tag(:meta, name: "auth-user-role", content: String.upcase(to_string(user_role))),
|
2020-06-27 17:12:45 +00:00
|
|
|
Tag.tag(:meta, name: "auth-user-actor-id", content: user_actor_id)
|
|
|
|
]
|
|
|
|
|
2021-03-09 18:39:54 +00:00
|
|
|
with tags <- Instance.build_tags() ++ info_tags,
|
2022-07-12 08:55:28 +00:00
|
|
|
assigns <- Map.put(assigns, :tags, tags) do
|
2022-09-21 06:32:42 +00:00
|
|
|
PageView.render("index.html", assigns)
|
2021-03-09 18:39:54 +00:00
|
|
|
end
|
2020-06-27 17:12:45 +00:00
|
|
|
end
|
|
|
|
end
|