mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:33:24 +08:00
FIX: redirect users after signing up with a social login when using SSO provider
This commit is contained in:
parent
f4e9d47a27
commit
be6404d651
|
@ -157,21 +157,18 @@ export default Ember.Controller.extend(ModalFunctionality, PasswordValidation, U
|
|||
},
|
||||
|
||||
createAccount() {
|
||||
const self = this,
|
||||
attrs = this.getProperties('accountName', 'accountEmail', 'accountPassword', 'accountUsername', 'accountPasswordConfirm', 'accountChallenge'),
|
||||
userFields = this.get('userFields');
|
||||
const attrs = this.getProperties('accountName', 'accountEmail', 'accountPassword', 'accountUsername', 'accountPasswordConfirm', 'accountChallenge');
|
||||
const userFields = this.get('userFields');
|
||||
|
||||
// Add the userfields to the data
|
||||
if (!Ember.isEmpty(userFields)) {
|
||||
attrs.userFields = {};
|
||||
userFields.forEach(function(f) {
|
||||
attrs.userFields[f.get('field.id')] = f.get('value');
|
||||
});
|
||||
userFields.forEach(f => attrs.userFields[f.get('field.id')] = f.get('value'));
|
||||
}
|
||||
|
||||
this.set('formSubmitted', true);
|
||||
return Discourse.User.createAccount(attrs).then(function(result) {
|
||||
self.set('isDeveloper', false);
|
||||
return Discourse.User.createAccount(attrs).then(result => {
|
||||
this.set('isDeveloper', false);
|
||||
if (result.success) {
|
||||
// Trigger the browser's password manager using the hidden static login form:
|
||||
const $hidden_login_form = $('#hidden-login-form');
|
||||
|
@ -180,24 +177,21 @@ export default Ember.Controller.extend(ModalFunctionality, PasswordValidation, U
|
|||
$hidden_login_form.find('input[name=redirect]').val(userPath('account-created'));
|
||||
$hidden_login_form.submit();
|
||||
} else {
|
||||
self.flash(result.message || I18n.t('create_account.failed'), 'error');
|
||||
this.flash(result.message || I18n.t('create_account.failed'), 'error');
|
||||
if (result.is_developer) {
|
||||
self.set('isDeveloper', true);
|
||||
this.set('isDeveloper', true);
|
||||
}
|
||||
if (result.errors && result.errors.email && result.errors.email.length > 0 && result.values) {
|
||||
self.get('rejectedEmails').pushObject(result.values.email);
|
||||
this.get('rejectedEmails').pushObject(result.values.email);
|
||||
}
|
||||
if (result.errors && result.errors.password && result.errors.password.length > 0) {
|
||||
self.get('rejectedPasswords').pushObject(attrs.accountPassword);
|
||||
this.get('rejectedPasswords').pushObject(attrs.accountPassword);
|
||||
}
|
||||
self.set('formSubmitted', false);
|
||||
this.set('formSubmitted', false);
|
||||
}
|
||||
if (result.active && !Discourse.SiteSettings.must_approve_users) {
|
||||
return window.location.reload();
|
||||
}
|
||||
}, function() {
|
||||
self.set('formSubmitted', false);
|
||||
return self.flash(I18n.t('create_account.failed'), 'error');
|
||||
}, () => {
|
||||
this.set('formSubmitted', false);
|
||||
return this.flash(I18n.t('create_account.failed'), 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -663,14 +663,17 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def account_created
|
||||
return redirect_to("/") if current_user.present?
|
||||
if current_user.present?
|
||||
if SiteSetting.enable_sso_provider && payload = cookies.delete(:sso_payload)
|
||||
return redirect_to(session_sso_provider_url + "?" + payload)
|
||||
else
|
||||
return redirect_to("/")
|
||||
end
|
||||
end
|
||||
|
||||
@custom_body_class = "static-account-created"
|
||||
@message = session['user_created_message'] || I18n.t('activation.missing_session')
|
||||
@account_created = {
|
||||
message: @message,
|
||||
show_controls: false
|
||||
}
|
||||
@account_created = { message: @message, show_controls: false }
|
||||
|
||||
if session_user_id = session[SessionController::ACTIVATE_USER_KEY]
|
||||
if user = User.where(id: session_user_id.to_i).first
|
||||
|
|
Loading…
Reference in New Issue
Block a user