Create action_fallback for username/password incorrect input
authorCalv Collins <calvcoll@gmail.com>
Thu, 8 Feb 2018 16:57:30 +0000 (16:57 +0000)
committerCalv Collins <calvcoll@gmail.com>
Thu, 8 Feb 2018 16:57:30 +0000 (16:57 +0000)
lib/pleroma/web/oauth/fallback_controller.ex [new file with mode: 0644]
lib/pleroma/web/oauth/oauth_controller.ex
lib/pleroma/web/templates/o_auth/o_auth/show.html.eex

diff --git a/lib/pleroma/web/oauth/fallback_controller.ex b/lib/pleroma/web/oauth/fallback_controller.ex
new file mode 100644 (file)
index 0000000..9ba9bc2
--- /dev/null
@@ -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
index e8483dec061ee0338678c13fdaca9c4c553eb34d..94318bfa91e604307431d160c5ccb62666c80bf8 100644 (file)
@@ -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"],
index 3c6903a16c775522873f17f6cae0ba93cf7f6c93..a7fa7523b80fc00a3feffe4777a4a472a6ea1869 100644 (file)
@@ -1,3 +1,5 @@
+<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
+<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
 <h2>OAuth Authorization</h2>
 <%= form_for @conn, o_auth_path(@conn, :authorize), [as: "authorization"], fn f -> %>
 <%= label f, :name, "Name" %>