mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
fixes invisible error message for comment rate limit, weird nesting error for tag updates, e.g. derpibooru/philomena#169
This commit is contained in:
parent
5249deb47f
commit
02bbf5e2f1
1 changed files with 13 additions and 0 deletions
|
@ -45,6 +45,12 @@ defmodule PhilomenaWeb.LimitPlug do
|
|||
is_staff(conn.assigns.current_user) ->
|
||||
conn
|
||||
|
||||
ajax?(conn) ->
|
||||
conn
|
||||
|> Controller.put_flash(:error, error)
|
||||
|> Conn.send_resp(:multiple_choices, "")
|
||||
|> Conn.halt()
|
||||
|
||||
true ->
|
||||
conn
|
||||
|> Controller.put_flash(:error, error)
|
||||
|
@ -60,4 +66,11 @@ defmodule PhilomenaWeb.LimitPlug do
|
|||
|
||||
defp current_user_id(%{id: id}), do: id
|
||||
defp current_user_id(_), do: nil
|
||||
|
||||
defp ajax?(conn) do
|
||||
case Conn.get_req_header(conn, "x-requested-with") do
|
||||
[value] -> String.downcase(value) == "xmlhttprequest"
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue