mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
FIX: redirect to original URL after social signup
This commit is contained in:
parent
4382fb5fac
commit
d8b543bb67
@ -205,6 +205,11 @@ export default Ember.Controller.extend(
|
||||
"accountChallenge"
|
||||
);
|
||||
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
|
||||
if (!Ember.isEmpty(userFields)) {
|
||||
@ -255,10 +260,12 @@ export default Ember.Controller.extend(
|
||||
this.get("rejectedPasswords").pushObject(attrs.accountPassword);
|
||||
}
|
||||
this.set("formSubmitted", false);
|
||||
$.cookie("destination_url", null);
|
||||
}
|
||||
},
|
||||
() => {
|
||||
this.set("formSubmitted", false);
|
||||
$.cookie("destination_url", null);
|
||||
return this.flash(I18n.t("create_account.failed"), "error");
|
||||
}
|
||||
);
|
||||
|
@ -675,6 +675,8 @@ class UsersController < ApplicationController
|
||||
if current_user.present?
|
||||
if SiteSetting.enable_sso_provider && payload = cookies.delete(:sso_payload)
|
||||
return redirect_to(session_sso_provider_url + "?" + payload)
|
||||
elsif destination_url = cookies.delete(:destination_url)
|
||||
return redirect_to(destination_url)
|
||||
else
|
||||
return redirect_to(path('/'))
|
||||
end
|
||||
|
@ -69,6 +69,8 @@ class Auth::Result
|
||||
email_valid: !!email_valid,
|
||||
omit_username: !!omit_username }
|
||||
|
||||
result[:destination_url] = destination_url if destination_url.present?
|
||||
|
||||
if SiteSetting.enable_names?
|
||||
result[:name] = User.suggest_name(name || username || email)
|
||||
end
|
||||
|
@ -2571,6 +2571,18 @@ describe UsersController do
|
||||
expect(response).to redirect_to("/")
|
||||
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
|
||||
include ApplicationHelper
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user