diff options
author | feld <feld@feld.me> | 2020-03-11 16:53:05 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-03-15 16:58:51 +0300 |
commit | e7837bc14e3fd539837802bca0c2ed05e2178ea5 (patch) | |
tree | b6a7574fd185cdcf43478a78eb846460c42b0e2c /lib/pleroma/web/mastodon_api/controllers | |
parent | e3ccaeaa532c692d391ac1a299e884a9914c9dc6 (diff) | |
download | pleroma-e7837bc14e3fd539837802bca0c2ed05e2178ea5.tar.gz |
Merge branch 'fix/signup-without-email' into 'develop'
Allow account registration without an email
See merge request pleroma/pleroma!2246
Diffstat (limited to 'lib/pleroma/web/mastodon_api/controllers')
-rw-r--r-- | lib/pleroma/web/mastodon_api/controllers/account_controller.ex | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex index dc3b47415..88c997b9f 100644 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@ -76,7 +76,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do @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 @@ -93,7 +93,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do |> 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", @@ -114,6 +115,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do 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) |