Make oauth pages translatable
[akkoma] / lib / pleroma / web / o_auth / o_auth_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.OAuth.OAuthView do
6 use Pleroma.Web, :view
7 import Phoenix.HTML.Form
8 import Phoenix.HTML
9 alias Pleroma.Web.Gettext
10
11 alias Pleroma.Web.OAuth.Token.Utils
12
13 def render("token.json", %{token: token} = opts) do
14 response = %{
15 id: token.id,
16 token_type: "Bearer",
17 access_token: token.token,
18 refresh_token: token.refresh_token,
19 expires_in: NaiveDateTime.diff(token.valid_until, NaiveDateTime.utc_now()),
20 scope: Enum.join(token.scopes, " "),
21 created_at: Utils.format_created_at(token)
22 }
23
24 if user = opts[:user] do
25 response
26 |> Map.put(:me, user.ap_id)
27 else
28 response
29 end
30 end
31 end