aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-06-14 01:45:10 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-06-14 02:07:43 +0000
commit4894b88b1b40705e8d5236d4b417ce2791e3b8fd (patch)
tree264835f68b08472628574e3ba9dd1c6a2b453d6d /lib
parentea42ba603fd0d3acd744f9f0b8ffb402e3ff1b2c (diff)
downloadpleroma-4894b88b1b40705e8d5236d4b417ce2791e3b8fd.tar.gz
oauth: support either name or username parameter with grant_type=password
closes #180
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/oauth/oauth_controller.ex14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex
index 3dd87d0ab..cdfae8b6a 100644
--- a/lib/pleroma/web/oauth/oauth_controller.ex
+++ b/lib/pleroma/web/oauth/oauth_controller.ex
@@ -81,7 +81,7 @@ defmodule Pleroma.Web.OAuth.OAuthController do
# - investigate a way to verify the user wants to grant read/write/follow once scope handling is done
def token_exchange(
conn,
- %{"grant_type" => "password", "name" => name, "password" => password} = params
+ %{"grant_type" => "password", "username" => name, "password" => password} = params
) do
with %App{} = app <- get_app_from_request(conn, params),
%User{} = user <- User.get_cached_by_nickname(name),
@@ -104,6 +104,18 @@ defmodule Pleroma.Web.OAuth.OAuthController do
end
end
+ def token_exchange(
+ conn,
+ %{"grant_type" => "password", "name" => name, "password" => password} = params
+ ) do
+ params =
+ params
+ |> Map.delete("name")
+ |> Map.put("username", name)
+
+ token_exchange(conn, params)
+ end
+
defp fix_padding(token) do
token
|> Base.url_decode64!(padding: false)