mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: Better error message for redeemed invite (#12580)
This commit improves the error message when a user tries to redeem a completely redeemed invite link.
This commit is contained in:
parent
cc2eb6e7b3
commit
81e5352e01
@ -52,7 +52,11 @@ class InvitesController < ApplicationController
|
||||
flash.now[:error] = if invite.blank?
|
||||
I18n.t('invite.not_found', base_url: Discourse.base_url)
|
||||
elsif invite.redeemed?
|
||||
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)
|
||||
end
|
||||
elsif invite.expired?
|
||||
I18n.t('invite.expired', base_url: Discourse.base_url)
|
||||
end
|
||||
|
@ -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>"
|
||||
|
@ -74,12 +74,19 @@ describe InvitesController do
|
||||
end
|
||||
|
||||
it '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))
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user