Mastodon-based auth error messages. Defaulted User#auth_active?/1 to `true`.
authorIvan Tashkinov <ivant.business@gmail.com>
Tue, 26 Mar 2019 12:09:06 +0000 (15:09 +0300)
committerIvan Tashkinov <ivant.business@gmail.com>
Tue, 26 Mar 2019 12:09:06 +0000 (15:09 +0300)
lib/pleroma/user.ex
lib/pleroma/web/oauth/oauth_controller.ex
test/web/oauth/oauth_controller_test.exs

index 41289b4d0591cb6cad4b07d768075726ba95d4b2..09d20b4325d7618f34c7ecc9ff7e38092cfbfb80 100644 (file)
@@ -60,14 +60,10 @@ defmodule Pleroma.User do
     timestamps()
   end
 
-  def auth_active?(%User{local: false}), do: true
-
-  def auth_active?(%User{info: %User.Info{confirmation_pending: false}}), do: true
-
   def auth_active?(%User{info: %User.Info{confirmation_pending: true}}),
     do: !Pleroma.Config.get([:instance, :account_activation_required])
 
-  def auth_active?(_), do: false
+  def auth_active?(%User{}), do: true
 
   def visible_for?(user, for_user \\ nil)
 
index d151efe9eb1fda98467517bb9e4594e0831f2018..be56f460a8de463c7acd76a077ef62eb41c0cdf0 100644 (file)
@@ -83,14 +83,16 @@ defmodule Pleroma.Web.OAuth.OAuthController do
       end
     else
       {scopes_issue, _} when scopes_issue in [:unsupported_scopes, :missing_scopes] ->
+        # Per https://github.com/tootsuite/mastodon/blob/51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L39
         conn
-        |> put_flash(:error, "Permissions not specified.")
+        |> put_flash(:error, "This action is outside the authorized scopes")
         |> put_status(:unauthorized)
         |> authorize(auth_params)
 
       {:auth_active, false} ->
+        # Per https://github.com/tootsuite/mastodon/blob/51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L76
         conn
-        |> put_flash(:error, "Account confirmation pending.")
+        |> put_flash(:error, "Your login is missing a confirmed e-mail address")
         |> put_status(:forbidden)
         |> authorize(auth_params)
 
@@ -149,9 +151,10 @@ defmodule Pleroma.Web.OAuth.OAuthController do
       json(conn, response)
     else
       {:auth_active, false} ->
+        # Per https://github.com/tootsuite/mastodon/blob/51e154f5e87968d6bb115e053689767ab33e80cd/app/controllers/api/base_controller.rb#L76
         conn
         |> put_status(:forbidden)
-        |> json(%{error: "Account confirmation pending"})
+        |> json(%{error: "Your login is missing a confirmed e-mail address"})
 
       _error ->
         put_status(conn, 400)
index ff1e56fe9d3e02c419889f2ec1c69bf96daeb84d..84ec7b4eef7354d15c53065f2800a0283eff9a9a 100644 (file)
@@ -87,7 +87,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
     assert result =~ app.redirect_uris
 
     # Error message
-    assert result =~ "Permissions not specified"
+    assert result =~ "This action is outside the authorized scopes"
   end
 
   test "returns 401 for scopes beyond app scopes", %{conn: conn} do
@@ -113,7 +113,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
     assert result =~ app.redirect_uris
 
     # Error message
-    assert result =~ "Permissions not specified"
+    assert result =~ "This action is outside the authorized scopes"
   end
 
   test "issues a token for an all-body request" do