diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 77dba98e5d4..c888cffab4d 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -19,16 +19,21 @@ class InvitesController < ApplicationController invite = Invite.find_by(invite_key: params[:id]) - if invite.present? && !invite.redeemed? - store_preloaded("invite_info", MultiJson.dump( - invited_by: UserNameSerializer.new(invite.invited_by, scope: guardian, root: false), - email: invite.email, - username: UserNameSuggester.suggest(invite.email)) - ) + if invite.present? + if !invite.redeemed? + store_preloaded("invite_info", MultiJson.dump( + invited_by: UserNameSerializer.new(invite.invited_by, scope: guardian, root: false), + email: invite.email, + username: UserNameSuggester.suggest(invite.email)) + ) - render layout: 'application' + render layout: 'application' + else + flash.now[:error] = I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url) + render layout: 'no_ember' + end else - flash.now[:error] = I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url) + flash.now[:error] = I18n.t('invite.not_found') render layout: 'no_ember' end end diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb index d51a3013edd..c2557e5c7c1 100644 --- a/spec/requests/invites_controller_spec.rb +++ b/spec/requests/invites_controller_spec.rb @@ -12,7 +12,7 @@ describe InvitesController do body = response.body expect(body).to_not have_tag(:script, with: { src: '/assets/application.js' }) - expect(CGI.unescapeHTML(body)).to include(I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url)) + expect(CGI.unescapeHTML(body)).to include(I18n.t('invite.not_found', site_name: SiteSetting.title, base_url: Discourse.base_url)) end it "renders the accept invite page if invite exists" do