From bdb5dd21943f886a1b4181aebd73e60662536e93 Mon Sep 17 00:00:00 2001 From: Calv Collins Date: Thu, 8 Feb 2018 16:57:30 +0000 Subject: [PATCH] Create action_fallback for username/password incorrect input --- lib/pleroma/web/oauth/fallback_controller.ex | 19 +++++++++++++++++++ lib/pleroma/web/oauth/oauth_controller.ex | 5 +++++ lib/pleroma/web/templates/o_auth/o_auth/show.html.eex | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 lib/pleroma/web/oauth/fallback_controller.ex diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex new file mode 100644 index 000000000..9ba9bc289 --- /dev/null +++ b/lib/pleroma/web/oauth/fallback_controller.ex @@ -0,0 +1,19 @@ +defmodule Pleroma.Web.OAuth.FallbackController do + use Pleroma.Web, :controller + alias Pleroma.Web.OAuth.OAuthController + + # No user + def call(conn, nil) do + conn + |> put_flash(:error, "Invalid Username/Password") + |> OAuthController.authorize(conn.params) + end + + # No password + def call(conn, false) do + conn + |> put_flash(:error, "Invalid Username/Password") + |> OAuthController.authorize(conn.params) + end + +end \ No newline at end of file diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index e8483dec0..94318bfa9 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -5,6 +5,11 @@ defmodule Pleroma.Web.OAuth.OAuthController do alias Pleroma.{Repo, User} alias Comeonin.Pbkdf2 + plug :fetch_session + plug :fetch_flash + + action_fallback Pleroma.Web.OAuth.FallbackController + def authorize(conn, params) do render conn, "show.html", %{ response_type: params["response_type"], diff --git a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex index 3c6903a16..a7fa7523b 100644 --- a/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex +++ b/lib/pleroma/web/templates/o_auth/o_auth/show.html.eex @@ -1,3 +1,5 @@ + +

OAuth Authorization

<%= form_for @conn, o_auth_path(@conn, :authorize), [as: "authorization"], fn f -> %> <%= label f, :name, "Name" %>