diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-06-14 07:14:18 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-06-14 07:14:18 +0000 |
commit | 2c303b3302e28a85aec448a9d57f9c5b1e658bfb (patch) | |
tree | 24ae24961221e66b2fd4e943578afd338d340631 /lib | |
parent | 280ac243aa8593cf5e16a96a0a887f5cbfce50d0 (diff) | |
parent | 4894b88b1b40705e8d5236d4b417ce2791e3b8fd (diff) | |
download | pleroma-2c303b3302e28a85aec448a9d57f9c5b1e658bfb.tar.gz |
Merge branch 'bugfix/oauth2-param-name' into 'develop'
oauth: support either name or username parameter with grant_type=password
Closes #180
See merge request pleroma/pleroma!219
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/oauth/oauth_controller.ex | 14 |
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 47962bbf8..a5fb32a4e 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_by_nickname_or_email(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) |