Merge branch 'improve_upgrade_user_from_ap_id' into 'develop'
[akkoma] / lib / pleroma / web / oauth / fallback_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 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(:error, "Unknown error, please check the details and try again.")
13 |> OAuthController.registration_details(conn.params)
14 end
15
16 def call(conn, {:register, _error}) do
17 conn
18 |> put_status(:unauthorized)
19 |> put_flash(:error, "Invalid Username/Password")
20 |> OAuthController.registration_details(conn.params)
21 end
22
23 def call(conn, _error) do
24 conn
25 |> put_status(:unauthorized)
26 |> put_flash(:error, "Invalid Username/Password")
27 |> OAuthController.authorize(conn.params["authorization"])
28 end
29 end