]> cat aescling's git repositories - mastodon.git/commitdiff
Add `email` param to `POST /api/v1/emails/confirmations` (#15949)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 25 Mar 2021 01:46:13 +0000 (02:46 +0100)
committerGitHub <noreply@github.com>
Thu, 25 Mar 2021 01:46:13 +0000 (02:46 +0100)
Allow changing e-mail as long as the account is unconfirmed

app/controllers/api/v1/emails/confirmations_controller.rb

index 03ab5de8c68f5d5b989db88413028ac4f1352005..4a7aa9c32a1a1f879ad2f903a2d228a250ae1ebf 100644 (file)
@@ -5,7 +5,11 @@ class Api::V1::Emails::ConfirmationsController < Api::BaseController
   before_action :require_user_owned_by_application!
 
   def create
-    current_user.resend_confirmation_instructions if current_user.unconfirmed_email.present?
+    if !current_user.confirmed? && current_user.unconfirmed_email.present?
+      current_user.update!(email: params[:email]) if params.key?(:email)
+      current_user.resend_confirmation_instructions
+    end
+
     render_empty
   end