A platform for community discussion. Free, open, simple.
UX: improve error message for already logged in users (#11020)
Arpit Jalan9aa2723d57cf
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rbindex 530f9e7db8e..fb4723c21fa 100644--- a/app/controllers/invites_controller.rb+++ b/app/controllers/invites_controller.rb@@ -254,7 +254,7 @@ class InvitesController < ApplicationControllerdef ensure_not_logged_inif current_user- flash[:error] = I18n.t("login.already_logged_in", current_user: current_user.username)+ flash[:error] = I18n.t("login.already_logged_in")render layout: 'no_ember'falseenddiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 444b85d9c8f..aa40f7f7050 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2452,7 +2452,7 @@ en:missing_user_field: "You have not completed all the user fields"auth_complete: "Authentication is complete."click_to_continue: "Click here to continue."- already_logged_in: "Oops, looks like you are attempting to accept an invitation for another user. If you are not %{current_user}, please log out and try again."+ already_logged_in: "Sorry! This invitation is intended for new users, who do not already have an existing account."second_factor_title: "Two-Factor Authentication"second_factor_description: "Please enter the required authentication code from your app:"second_factor_backup_description: "Please enter one of your backup codes:"diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rbindex 995ded2a21a..0648dc17dce 100644--- a/spec/requests/invites_controller_spec.rb+++ b/spec/requests/invites_controller_spec.rb@@ -10,6 +10,15 @@ describe InvitesController dofab!(:invite) { Fabricate(:invite) }fab!(:user) { Fabricate(:coding_horror) }+ it 'does not work for logged in users' do+ sign_in(Fabricate(:user))+ get "/invites/#{invite.invite_key}"++ expect(response.status).to eq(200)+ body = response.body+ expect(CGI.unescapeHTML(body)).to include(I18n.t("login.already_logged_in"))+ end+it "returns error if invite not found" doget "/invites/nopeNOPEnope"