Parse access_token from body parameters and URL parameters
authorAkiraFukushima <h3.poteto@gmail.com>
Thu, 2 May 2019 12:04:00 +0000 (21:04 +0900)
committerAkiraFukushima <h3.poteto@gmail.com>
Thu, 2 May 2019 12:04:00 +0000 (21:04 +0900)
lib/pleroma/plugs/oauth_plug.ex

index 5888d596aaaf4ae89df271be0166eabb13b75152..9d43732eb43592cbafe41c6f2a08c947836ee44c 100644 (file)
@@ -16,6 +16,16 @@ defmodule Pleroma.Plugs.OAuthPlug do
 
   def call(%{assigns: %{user: %User{}}} = conn, _), do: conn
 
+  def call(%{params: %{"access_token" => access_token}} = conn, _) do
+    with {:ok, user, token_record} <- fetch_user_and_token(access_token) do
+      conn
+      |> assign(:token, token_record)
+      |> assign(:user, user)
+    else
+      _ -> conn
+    end
+  end
+
   def call(conn, _) do
     with {:ok, token_str} <- fetch_token_str(conn),
          {:ok, user, token_record} <- fetch_user_and_token(token_str) do