mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:41:17 +08:00
FIX: redirect to original URL after social signup
This commit is contained in:
@ -205,6 +205,11 @@ export default Ember.Controller.extend(
|
|||||||
"accountChallenge"
|
"accountChallenge"
|
||||||
);
|
);
|
||||||
const userFields = this.get("userFields");
|
const userFields = this.get("userFields");
|
||||||
|
const destinationUrl = this.get("authOptions.destination_url");
|
||||||
|
|
||||||
|
if (!Ember.isEmpty(destinationUrl)) {
|
||||||
|
$.cookie("destination_url", destinationUrl, { path: '/' });
|
||||||
|
}
|
||||||
|
|
||||||
// Add the userfields to the data
|
// Add the userfields to the data
|
||||||
if (!Ember.isEmpty(userFields)) {
|
if (!Ember.isEmpty(userFields)) {
|
||||||
@ -255,10 +260,12 @@ export default Ember.Controller.extend(
|
|||||||
this.get("rejectedPasswords").pushObject(attrs.accountPassword);
|
this.get("rejectedPasswords").pushObject(attrs.accountPassword);
|
||||||
}
|
}
|
||||||
this.set("formSubmitted", false);
|
this.set("formSubmitted", false);
|
||||||
|
$.cookie("destination_url", null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
this.set("formSubmitted", false);
|
this.set("formSubmitted", false);
|
||||||
|
$.cookie("destination_url", null);
|
||||||
return this.flash(I18n.t("create_account.failed"), "error");
|
return this.flash(I18n.t("create_account.failed"), "error");
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -675,6 +675,8 @@ class UsersController < ApplicationController
|
|||||||
if current_user.present?
|
if current_user.present?
|
||||||
if SiteSetting.enable_sso_provider && payload = cookies.delete(:sso_payload)
|
if SiteSetting.enable_sso_provider && payload = cookies.delete(:sso_payload)
|
||||||
return redirect_to(session_sso_provider_url + "?" + payload)
|
return redirect_to(session_sso_provider_url + "?" + payload)
|
||||||
|
elsif destination_url = cookies.delete(:destination_url)
|
||||||
|
return redirect_to(destination_url)
|
||||||
else
|
else
|
||||||
return redirect_to(path('/'))
|
return redirect_to(path('/'))
|
||||||
end
|
end
|
||||||
|
@ -69,6 +69,8 @@ class Auth::Result
|
|||||||
email_valid: !!email_valid,
|
email_valid: !!email_valid,
|
||||||
omit_username: !!omit_username }
|
omit_username: !!omit_username }
|
||||||
|
|
||||||
|
result[:destination_url] = destination_url if destination_url.present?
|
||||||
|
|
||||||
if SiteSetting.enable_names?
|
if SiteSetting.enable_names?
|
||||||
result[:name] = User.suggest_name(name || username || email)
|
result[:name] = User.suggest_name(name || username || email)
|
||||||
end
|
end
|
||||||
|
@ -2571,6 +2571,18 @@ describe UsersController do
|
|||||||
expect(response).to redirect_to("/")
|
expect(response).to redirect_to("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when cookies contains a destination URL' do
|
||||||
|
it 'should redirect to the URL' do
|
||||||
|
sign_in(Fabricate(:user))
|
||||||
|
destination_url = 'http://thisisasite.com/somepath'
|
||||||
|
cookies[:destination_url] = destination_url
|
||||||
|
|
||||||
|
get "/u/account-created"
|
||||||
|
|
||||||
|
expect(response).to redirect_to(destination_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when the user account is created" do
|
context "when the user account is created" do
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user