aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/oauth/oauth_controller.ex
diff options
context:
space:
mode:
authorsquidboi <squidboi@waifu.club>2018-06-16 15:37:16 -0700
committersquidboi <squidboi@waifu.club>2018-06-16 15:37:16 -0700
commit2e294ee44a1baa7c0d3ac6b2905a70ed4e05cffb (patch)
tree740d660abc0ca455368144abc89c8a398e85caf0 /lib/pleroma/web/oauth/oauth_controller.ex
parent4f9ecfc77a54eef23741c89206b4cbce924f7d76 (diff)
parent1ea4a18ad859600841860cdd1a981da868aa18a0 (diff)
downloadpleroma-2e294ee44a1baa7c0d3ac6b2905a70ed4e05cffb.tar.gz
Merge branch 'develop' into feature/configurable-blocks
Diffstat (limited to 'lib/pleroma/web/oauth/oauth_controller.ex')
-rw-r--r--lib/pleroma/web/oauth/oauth_controller.ex16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex
index 3dd87d0ab..a5fb32a4e 100644
--- a/lib/pleroma/web/oauth/oauth_controller.ex
+++ b/lib/pleroma/web/oauth/oauth_controller.ex
@@ -81,10 +81,10 @@ 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),
+ %User{} = user <- User.get_by_nickname_or_email(name),
true <- Pbkdf2.checkpw(password, user.password_hash),
{:ok, auth} <- Authorization.create_authorization(app, user),
{:ok, token} <- Token.exchange_token(app, auth) do
@@ -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)