diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6 index 9b3528f32b4..1ac854e9fa1 100644 --- a/app/assets/javascripts/discourse/controllers/create-account.js.es6 +++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6 @@ -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'); }); } } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cca0a636588..5b47b9c6f64 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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