about summary refs log tree commit diff
path: root/app/controllers/auth/confirmations_controller.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-02-04 16:36:19 -0600
committerDavid Yip <yipdw@member.fsf.org>2018-02-04 16:36:19 -0600
commita6fb1c58eead1357a307813c69f798f32bcf7cae (patch)
treed56d2721705d86a925279a737943cbaa28a60979 /app/controllers/auth/confirmations_controller.rb
parent530fcc1c14d2b7a38c1b734c0b18955f109f0f20 (diff)
parent38e0133e1b01c21a710111097102a6eb205b9b9b (diff)
Merge remote-tracking branch 'origin/master' into merge-upstream
 Conflicts:
	.env.production.sample
	app/controllers/auth/confirmations_controller.rb
	db/schema.rb
Diffstat (limited to 'app/controllers/auth/confirmations_controller.rb')
-rw-r--r--app/controllers/auth/confirmations_controller.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/auth/confirmations_controller.rb b/app/controllers/auth/confirmations_controller.rb
index 72b8e9dd8..f3e0ae257 100644
--- a/app/controllers/auth/confirmations_controller.rb
+++ b/app/controllers/auth/confirmations_controller.rb
@@ -3,6 +3,7 @@
 class Auth::ConfirmationsController < Devise::ConfirmationsController
   layout 'auth'
 
+  before_action :set_user, only: [:finish_signup]
   before_action :set_pack
 
   private
@@ -10,4 +11,26 @@ class Auth::ConfirmationsController < Devise::ConfirmationsController
   def set_pack
     use_pack 'auth'
   end
+
+  # GET/PATCH /users/:id/finish_signup
+  def finish_signup
+    return unless request.patch? && params[:user]
+    if @user.update(user_params)
+      @user.skip_reconfirmation!
+      sign_in(@user, bypass: true)
+      redirect_to root_path, notice: I18n.t('devise.confirmations.send_instructions')
+    else
+      @show_errors = true
+    end
+  end
+
+  private
+
+  def set_user
+    @user = current_user
+  end
+
+  def user_params
+    params.require(:user).permit(:email)
+  end
 end