Merge branch 'issue/2069' into 'develop'
[akkoma] / lib / pleroma / web / o_auth / fallback_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.OAuth.FallbackController do
6 use Pleroma.Web, :controller
7 alias Pleroma.Web.OAuth.OAuthController
8
9 def call(conn, {:register, :generic_error}) do
10 conn
11 |> put_status(:internal_server_error)
12 |> put_flash(
13 :error,
14 dgettext("errors", "Unknown error, please check the details and try again.")
15 )
16 |> OAuthController.registration_details(conn.params)
17 end
18
19 def call(conn, {:register, _error}) do
20 conn
21 |> put_status(:unauthorized)
22 |> put_flash(:error, dgettext("errors", "Invalid Username/Password"))
23 |> OAuthController.registration_details(conn.params)
24 end
25
26 def call(conn, _error) do
27 conn
28 |> put_status(:unauthorized)
29 |> put_flash(:error, dgettext("errors", "Invalid Username/Password"))
30 |> OAuthController.authorize(conn.params)
31 end
32 end