UX: improve error message for already logged in users (#11020)

This commit is contained in:
Arpit Jalan 2020-10-24 21:21:01 +05:30 committed by GitHub
parent e246208756
commit 9aa2723d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -254,7 +254,7 @@ class InvitesController < ApplicationController
def ensure_not_logged_in
if 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'
false
end

View File

@ -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:"

View File

@ -10,6 +10,15 @@ describe InvitesController do
fab!(: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" do
get "/invites/nopeNOPEnope"