diff --git a/app/assets/javascripts/discourse/controllers/create-account.js.es6 b/app/assets/javascripts/discourse/controllers/create-account.js.es6 index 7d846513b55..198c0d04f45 100644 --- a/app/assets/javascripts/discourse/controllers/create-account.js.es6 +++ b/app/assets/javascripts/discourse/controllers/create-account.js.es6 @@ -362,9 +362,10 @@ export default DiscourseController.extend(ModalFunctionality, { if (result.success) { // Trigger the browser's password manager using the hidden static login form: var $hidden_login_form = $('#hidden-login-form'); + var account_created_url = Discourse.getURL('/users/' + self.get('accountUsername') + '/account-created'); $hidden_login_form.find('input[name=username]').val(attrs.accountName); $hidden_login_form.find('input[name=password]').val(attrs.accountPassword); - $hidden_login_form.find('input[name=redirect]').val(Discourse.getURL('/users/account-created')); + $hidden_login_form.find('input[name=redirect]').val(account_created_url); $hidden_login_form.submit(); } else { self.flash(result.message || I18n.t('create_account.failed'), 'error'); diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 806315ca8f2..6489cd2c7d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -338,6 +338,11 @@ class UsersController < ApplicationController end def account_created + params.require(:username) + @user = User.find_by_username_or_email(params[:username].to_s) + + raise Discourse::NotFound unless @user + expires_now render layout: 'no_js' end diff --git a/app/views/users/account_created.html.erb b/app/views/users/account_created.html.erb index ce13d4f1427..b4220481273 100644 --- a/app/views/users/account_created.html.erb +++ b/app/views/users/account_created.html.erb @@ -1,3 +1,3 @@
You're almost done! We sent an activation mail to %{email}. Please follow the instructions in the email to activate your account.
If it doesn't arrive, check your spam folder, or try to log in again to send another activation mail.
" not_activated: "You can't log in yet. We sent an activation email to you. Please follow the instructions in the email to activate your account." not_allowed_from_ip_address: "You can't login as %{username} from that IP address." suspended: "You can't log in until %{date}." diff --git a/config/routes.rb b/config/routes.rb index 8d9c0a6abf0..f0ca22f324b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -207,7 +207,7 @@ Discourse::Application.routes.draw do post "users/read-faq" => "users#read_faq" get "users/search/users" => "users#search_users" - get "users/account-created/" => "users#account_created" + get "users/:username/account-created" => "users#account_created", constraints: {username: USERNAME_ROUTE_FORMAT} get "users/password-reset/:token" => "users#password_reset" put "users/password-reset/:token" => "users#password_reset" get "users/activate-account/:token" => "users#activate_account"