Support both OAuth token record and token string in UserView

This commit is contained in:
raeno 2018-12-17 16:02:26 +01:00
parent 567359790e
commit cc87880488

View file

@ -86,7 +86,7 @@ def render("user.json", %{user: user = %User{}} = assigns) do
}
if assigns[:token] do
Map.put(data, "token", assigns[:token])
Map.put(data, "token", token_string(assigns[:token]))
else
data
end
@ -111,4 +111,7 @@ def render("short.json", %{
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
defp image_url(_), do: nil
defp token_string(%Pleroma.Web.OAuth.Token{token: token_str}), do: token_str
defp token_string(token), do: token
end