diff options
author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2018-12-13 17:58:40 +0300 |
---|---|---|
committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2018-12-14 12:28:22 +0300 |
commit | 3cbf16a5fe9f7618cae557eb260093881febd1d1 (patch) | |
tree | bb5a2cb0f424ed760c22cc7e71a3f9580fa7e8fe /lib | |
parent | cc83d7ffe786f639172e28005e2912a0bad26234 (diff) | |
download | pleroma-3cbf16a5fe9f7618cae557eb260093881febd1d1.tar.gz |
[#114] Added UserInviteToken creation, adjusted invitation email link to include it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/emails/user_email.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api_controller.ex | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex index 47dcd42e0..ee41ce50a 100644 --- a/lib/pleroma/emails/user_email.ex +++ b/lib/pleroma/emails/user_email.ex @@ -38,12 +38,12 @@ defmodule Pleroma.UserEmail do |> html_body(html_body) end - def user_invitation_email(user, to_email, to_name \\ nil) do + def user_invitation_email(user, user_invite_token, to_email, to_name \\ nil) do registration_url = Router.Helpers.redirect_url( Endpoint, :registration_page, - "" + user_invite_token.token ) html_body = """ diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index d51d71299..0607a1a6a 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -336,8 +336,12 @@ defmodule Pleroma.Web.TwitterAPI.Controller do def confirm_email(_conn, _params), do: :noop def email_invite(%{assigns: %{user: user}} = conn, %{"email" => email} = params) do - with true <- Pleroma.Config.get([:instance, :invites_enabled]), - email <- Pleroma.UserEmail.user_invitation_email(user, email, params["name"]), + with true <- + Pleroma.Config.get([:instance, :invites_enabled]) && + !Pleroma.Config.get([:instance, :registrations_open]), + {:ok, invite_token} <- Pleroma.UserInviteToken.create_token(), + email <- + Pleroma.UserEmail.user_invitation_email(user, invite_token, email, params["name"]), {:ok, _} <- Pleroma.Mailer.deliver(email) do json_response(conn, :no_content, "") end |