From d16b6139299e47777c68eca819e75f85f71a8156 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 23 Nov 2017 12:06:14 +0100 Subject: [PATCH] MastodonUI login: Show error message on error. --- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 6 +++++- .../web/templates/mastodon_api/mastodon/login.html.eex | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index fc7f21096..82887966c 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -559,7 +559,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def login(conn, _) do conn - |> render(MastodonView, "login.html") + |> render(MastodonView, "login.html", %{error: false}) end defp get_or_make_app() do @@ -581,6 +581,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do conn |> put_session(:oauth_token, token.token) |> redirect(to: "/web/getting-started") + else + _e -> + conn + |> render(MastodonView, "login.html", %{error: "Wrong username or password"}) end end diff --git a/lib/pleroma/web/templates/mastodon_api/mastodon/login.html.eex b/lib/pleroma/web/templates/mastodon_api/mastodon/login.html.eex index 89d97561b..2ef67b901 100644 --- a/lib/pleroma/web/templates/mastodon_api/mastodon/login.html.eex +++ b/lib/pleroma/web/templates/mastodon_api/mastodon/login.html.eex @@ -1,4 +1,7 @@

Login in to Mastodon Frontend

+<%= if @error do %> +

<%= @error %>

+<% end %> <%= form_for @conn, mastodon_api_path(@conn, :login), [as: "authorization"], fn f -> %> <%= text_input f, :name, placeholder: "Username" %>
-- 2.45.2