FIX: better error message if invite is expired (#10783)
https://meta.discourse.org/t/invite-token-is-invalid/165270/5?u=techapj
This commit is contained in:
parent
a13497dd1f
commit
ff44515a18
|
@ -18,23 +18,23 @@ class InvitesController < ApplicationController
|
|||
expires_now
|
||||
|
||||
invite = Invite.find_by(invite_key: params[:id])
|
||||
if invite.present? && !invite.expired? && !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),
|
||||
is_invite_link: invite.is_invite_link?)
|
||||
)
|
||||
|
||||
if invite.present? && !invite.expired?
|
||||
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),
|
||||
is_invite_link: invite.is_invite_link?)
|
||||
)
|
||||
|
||||
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
|
||||
render layout: 'application'
|
||||
else
|
||||
flash.now[:error] = I18n.t('invite.not_found', base_url: Discourse.base_url)
|
||||
flash.now[:error] = if invite.present? && invite.expired?
|
||||
I18n.t('invite.expired', base_url: Discourse.base_url)
|
||||
elsif invite.present? && invite.redeemed?
|
||||
I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url)
|
||||
else
|
||||
I18n.t('invite.not_found', base_url: Discourse.base_url)
|
||||
end
|
||||
render layout: 'no_ember'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -205,6 +205,7 @@ en:
|
|||
<<: *errors
|
||||
|
||||
invite:
|
||||
expired: "Your invite token is expired. Please <a href='%{base_url}/about'>contact staff</a>."
|
||||
not_found: "Your invite token is invalid. Please <a href='%{base_url}/about'>contact staff</a>."
|
||||
not_found_json: "Your invite token is invalid. Please contact staff."
|
||||
not_found_template: |
|
||||
|
|
|
@ -29,7 +29,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', base_url: Discourse.base_url))
|
||||
expect(CGI.unescapeHTML(body)).to include(I18n.t('invite.expired', base_url: Discourse.base_url))
|
||||
end
|
||||
|
||||
it "renders the accept invite page if invite exists" do
|
||||
|
|
Loading…
Reference in New Issue