projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'remotes/origin/develop' into clear-config-test-improvements
[akkoma]
/
lib
/
pleroma
/
web
/
mastodon_api
/
controllers
/
account_controller.ex
diff --git
a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index 38d14256f53aeeb1bfbd8a5d996c5433e66a2fd0..6dbf11ac92ff080f470d7df30277ff52f0a945fc 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AccountController do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AccountController do
@@
-60,7
+60,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
plug(
Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
plug(
Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
- when action
!= :create
+ when action
not in [:create, :show, :statuses]
)
@relations [:follow, :unfollow]
)
@relations [:follow, :unfollow]
@@
-76,7
+76,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
@doc "POST /api/v1/accounts"
def create(
%{assigns: %{app: app}} = conn,
@doc "POST /api/v1/accounts"
def create(
%{assigns: %{app: app}} = conn,
- %{"username" => nickname, "
email" => _, "
password" => _, "agreement" => true} = params
+ %{"username" => nickname, "password" => _, "agreement" => true} = params
) do
params =
params
) do
params =
params
@@
-93,7
+93,8
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
|> Map.put("bio", params["bio"] || "")
|> Map.put("confirm", params["password"])
|> Map.put("bio", params["bio"] || "")
|> Map.put("confirm", params["password"])
- with {:ok, user} <- TwitterAPI.register_user(params, need_confirmation: true),
+ with :ok <- validate_email_param(params),
+ {:ok, user} <- TwitterAPI.register_user(params, need_confirmation: true),
{:ok, token} <- Token.create_token(app, user, %{scopes: app.scopes}) do
json(conn, %{
token_type: "Bearer",
{:ok, token} <- Token.create_token(app, user, %{scopes: app.scopes}) do
json(conn, %{
token_type: "Bearer",
@@
-114,6
+115,15
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
render_error(conn, :forbidden, "Invalid credentials")
end
render_error(conn, :forbidden, "Invalid credentials")
end
+ defp validate_email_param(%{"email" => _}), do: :ok
+
+ defp validate_email_param(_) do
+ case Pleroma.Config.get([:instance, :account_activation_required]) do
+ true -> {:error, %{"error" => "Missing parameters"}}
+ _ -> :ok
+ end
+ end
+
@doc "GET /api/v1/accounts/verify_credentials"
def verify_credentials(%{assigns: %{user: user}} = conn, _) do
chat_token = Phoenix.Token.sign(conn, "user socket", user.id)
@doc "GET /api/v1/accounts/verify_credentials"
def verify_credentials(%{assigns: %{user: user}} = conn, _) do
chat_token = Phoenix.Token.sign(conn, "user socket", user.id)
@@
-249,7
+259,8
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
@doc "GET /api/v1/accounts/:id/statuses"
def statuses(%{assigns: %{user: reading_user}} = conn, params) do
@doc "GET /api/v1/accounts/:id/statuses"
def statuses(%{assigns: %{user: reading_user}} = conn, params) do
- with %User{} = user <- User.get_cached_by_nickname_or_id(params["id"], for: reading_user) do
+ with %User{} = user <- User.get_cached_by_nickname_or_id(params["id"], for: reading_user),
+ true <- User.visible_for?(user, reading_user) do
params =
params
|> Map.put("tag", params["tagged"])
params =
params
|> Map.put("tag", params["tagged"])
@@
-261,6
+272,8
@@
defmodule Pleroma.Web.MastodonAPI.AccountController do
|> add_link_headers(activities)
|> put_view(StatusView)
|> render("index.json", activities: activities, for: reading_user, as: :activity)
|> add_link_headers(activities)
|> put_view(StatusView)
|> render("index.json", activities: activities, for: reading_user, as: :activity)
+ else
+ _e -> render_error(conn, :not_found, "Can't find user")
end
end
end
end