logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

o_auth_view.ex (838B)


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