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
This commit is contained in:
commit
2c303b3302
@ -81,7 +81,7 @@ def token_exchange(conn, %{"grant_type" => "authorization_code"} = params) 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 @@ def token_exchange(
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user