From 81190f5d66939d002d47c371854948a875e6581d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 3 May 2017 11:15:54 -0400 Subject: [PATCH] FIX: Redirect away from `account-created` if you're logged in --- app/controllers/users_controller.rb | 2 ++ spec/controllers/users_controller_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5289d7554b5..dbe6950e8f4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -533,6 +533,8 @@ class UsersController < ApplicationController end def account_created + return redirect_to("/") if current_user.present? + @custom_body_class = "static-account-created" @message = session['user_created_message'] || I18n.t('activation.missing_session') @account_created = { message: @message } diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 8d726512397..fab6193a921 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -2008,6 +2008,12 @@ describe UsersController do expect(created[:username]).to be_blank end + it "redirects when the user is logged in" do + log_in(:user) + get :account_created + expect(response).to be_redirect + end + context "when the user account is created" do before do session['user_created_message'] = "Donuts"