diff options
author | href <href+git-pleroma@random.sh> | 2019-01-28 10:49:03 +0000 |
---|---|---|
committer | href <href+git-pleroma@random.sh> | 2019-01-28 10:49:03 +0000 |
commit | 74ed1b4d87f5ee5570966179bc6094ac0be09533 (patch) | |
tree | 0ffcbec2140210ab26f93226d7c43179d5790d16 | |
parent | b380b4898d3165c41a0e2b09b0727cad6b58f925 (diff) | |
parent | 1825118fd46883cb2a9132b039925c160ad7e57b (diff) | |
download | pleroma-74ed1b4d87f5ee5570966179bc6094ac0be09533.tar.gz |
Merge branch 'oauth-login-failure-bug' into 'develop'
Correctly handle invalid credentials on auth login.
Closes #407
See merge request pleroma/pleroma!728
-rw-r--r-- | lib/pleroma/web/oauth/fallback_controller.ex | 3 | ||||
-rw-r--r-- | test/web/oauth/oauth_controller_test.exs | 25 |
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex index 1eeda3d24..f0fe3b578 100644 --- a/lib/pleroma/web/oauth/fallback_controller.ex +++ b/lib/pleroma/web/oauth/fallback_controller.ex @@ -9,7 +9,8 @@ defmodule Pleroma.Web.OAuth.FallbackController do # No user/password def call(conn, _) do conn + |> put_status(:unauthorized) |> put_flash(:error, "Invalid Username/Password") - |> OAuthController.authorize(conn.params) + |> OAuthController.authorize(conn.params["authorization"]) end end diff --git a/test/web/oauth/oauth_controller_test.exs b/test/web/oauth/oauth_controller_test.exs index ccd552258..e0d3cb55f 100644 --- a/test/web/oauth/oauth_controller_test.exs +++ b/test/web/oauth/oauth_controller_test.exs @@ -34,6 +34,31 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do assert Repo.get_by(Authorization, token: code) end + test "correctly handles wrong credentials", %{conn: conn} do + user = insert(:user) + app = insert(:oauth_app) + + result = + conn + |> post("/oauth/authorize", %{ + "authorization" => %{ + "name" => user.nickname, + "password" => "wrong", + "client_id" => app.client_id, + "redirect_uri" => app.redirect_uris, + "state" => "statepassed" + } + }) + |> html_response(:unauthorized) + + # Keep the details + assert result =~ app.client_id + assert result =~ app.redirect_uris + + # Error message + assert result =~ "Invalid" + end + test "issues a token for an all-body request" do user = insert(:user) app = insert(:oauth_app) |