Browse Source

Correctly handle invalid credentials on auth login.

Closes #407
tags/v0.9.9
lain 5 years ago
parent
commit
1825118fd4
2 changed files with 27 additions and 1 deletions
  1. +2
    -1
      lib/pleroma/web/oauth/fallback_controller.ex
  2. +25
    -0
      test/web/oauth/oauth_controller_test.exs

+ 2
- 1
lib/pleroma/web/oauth/fallback_controller.ex View File

@@ -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

+ 25
- 0
test/web/oauth/oauth_controller_test.exs View File

@@ -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)


Loading…
Cancel
Save