From 533d8cd5816343ccfb6e26495124416e9808554c Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 2 May 2019 21:04:00 +0900
Subject: [PATCH] Parse access_token from body parameters and URL parameters
---
lib/pleroma/plugs/oauth_plug.ex | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/pleroma/plugs/oauth_plug.ex b/lib/pleroma/plugs/oauth_plug.ex
index 5888d596a..9d43732eb 100644
--- a/lib/pleroma/plugs/oauth_plug.ex
+++ b/lib/pleroma/plugs/oauth_plug.ex
@@ -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