FIX: show accurate error message based on invite token validity
This commit is contained in:
parent
a953b71797
commit
bea7a8a4d1
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue