mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FIX: better accept invite flow when user is invited via a link
This commit is contained in:
parent
77d947701c
commit
e0bc82657b
@ -94,8 +94,9 @@ export default Ember.Controller.extend(
|
||||
"successMessage",
|
||||
result.message || I18n.t("invites.success")
|
||||
);
|
||||
this.set("redirectTo", result.redirect_to);
|
||||
DiscourseURL.redirectTo(result.redirect_to || "/");
|
||||
if (result.redirect_to) {
|
||||
DiscourseURL.redirectTo(result.redirect_to || "/");
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
result.errors &&
|
||||
|
@ -8,13 +8,12 @@
|
||||
</div>
|
||||
|
||||
<div class="col-form">
|
||||
<p>{{i18n 'invites.invited_by'}}</p>
|
||||
|
||||
<p>{{user-info user=invitedBy}}</p>
|
||||
|
||||
{{#if successMessage}}
|
||||
<p>{{successMessage}}</p>
|
||||
<br/><br/>
|
||||
<div class='alert alert-info'><p>{{{successMessage}}}</p></div>
|
||||
{{else}}
|
||||
<p>{{i18n 'invites.invited_by'}}</p>
|
||||
<p>{{user-info user=invitedBy}}</p>
|
||||
|
||||
<p>{{{yourEmailMessage}}}
|
||||
{{#if externalAuthsEnabled}}
|
||||
@ -63,7 +62,6 @@
|
||||
<br/><br/>
|
||||
<div class='alert alert-error'>{{errorMessage}}</div>
|
||||
{{/if}}
|
||||
|
||||
</form>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
@ -47,16 +47,19 @@ class InvitesController < ApplicationController
|
||||
begin
|
||||
user = invite.redeem(username: params[:username], name: params[:name], password: params[:password], user_custom_fields: params[:user_custom_fields])
|
||||
if user.present?
|
||||
log_on_user(user)
|
||||
log_on_user(user) if user.active?
|
||||
post_process_invite(user)
|
||||
end
|
||||
|
||||
topic = user.present? ? invite.topics.first : nil
|
||||
response = { success: true }
|
||||
if user.present? && user.active?
|
||||
topic = invite.topics.first
|
||||
response[:redirect_to] = topic.present? ? path("#{topic.relative_url}") : path("/")
|
||||
else
|
||||
response[:message] = I18n.t('invite.confirm_email')
|
||||
end
|
||||
|
||||
render json: {
|
||||
success: true,
|
||||
redirect_to: topic.present? ? path("#{topic.relative_url}") : path("/")
|
||||
}
|
||||
render json: response
|
||||
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
|
||||
render json: {
|
||||
success: false,
|
||||
|
@ -185,6 +185,7 @@ en:
|
||||
|
||||
<p>Otherwise please <a href="%{base_url}/password-reset">Reset Password</a>.</p>
|
||||
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>"
|
||||
|
||||
bulk_invite:
|
||||
file_should_be_csv: "The uploaded file should be of csv format."
|
||||
|
@ -355,6 +355,7 @@ describe InvitesController do
|
||||
put "/invites/show/#{invite.invite_key}.json", params: { password: "verystrongpassword" }
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)["success"]).to eq(true)
|
||||
expect(JSON.parse(response.body)["message"]).to eq(I18n.t("invite.confirm_email"))
|
||||
|
||||
invited_user = User.find_by_email(invite.email)
|
||||
expect(invited_user.active).to eq(false)
|
||||
|
Loading…
Reference in New Issue
Block a user