A platform for community discussion. Free, open, simple.
FIX: Better error message for redeemed invite (#12580)
Dan Ungureanu81e5352e013f
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rbindex f6b89456285..bdff1454de3 100644--- a/app/controllers/invites_controller.rb+++ b/app/controllers/invites_controller.rb@@ -52,7 +52,11 @@ class InvitesController < ApplicationControllerflash.now[:error] = if invite.blank?I18n.t('invite.not_found', base_url: Discourse.base_url)elsif invite.redeemed?- I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url)+ if invite.is_invite_link?+ I18n.t('invite.not_found_template_link', site_name: SiteSetting.title, base_url: Discourse.base_url)+ else+ I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url)+ endelsif invite.expired?I18n.t('invite.expired', base_url: Discourse.base_url)enddiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 4e1ca38f6b0..47b69810a61 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -236,6 +236,8 @@ en:<p>If you remember your password you can <a href="%{base_url}/login">Log In</a>.</p><p>Otherwise please <a href="%{base_url}/password-reset">Reset Password</a>.</p>+ not_found_template_link: |+ <p>The invitation to <a href="%{base_url}">%{site_name}</a> can no longer be redeemed. Please ask the person who invited you to send you a new invitation.</p>error_message: "There was an error accepting invite. Please contact the site's administrator."user_exists: "There's no need to invite <b>%{email}</b>, they <a href='%{base_path}/u/%{username}/summary'>already have an account!</a>"confirm_email: "<p>You’re almost done! We sent an activation mail to your email address. Please follow the instructions in the mail to activate your account.</p><p>If it doesn’t arrive, check your spam folder.</p>"diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rbindex 5bd12892242..6e3d810f247 100644--- a/spec/requests/invites_controller_spec.rb+++ b/spec/requests/invites_controller_spec.rb@@ -74,12 +74,19 @@ describe InvitesController doendit 'returns error if invite has already been redeemed' do- Fabricate(:invited_user, invite: invite, user: Fabricate(:user))+ expect(invite.redeem).not_to eq(nil)get "/invites/#{invite.invite_key}"expect(response.status).to eq(200)expect(response.body).to_not have_tag(:script, with: { src: '/assets/application.js' })expect(response.body).to include(I18n.t('invite.not_found_template', site_name: SiteSetting.title, base_url: Discourse.base_url))++ invite.update!(email: nil) # convert to email invite++ get "/invites/#{invite.invite_key}"+ expect(response.status).to eq(200)+ expect(response.body).to_not have_tag(:script, with: { src: '/assets/application.js' })+ expect(response.body).to include(I18n.t('invite.not_found_template_link', site_name: SiteSetting.title, base_url: Discourse.base_url))endend