diff --git a/app/controllers/ui/users_controller.rb b/app/controllers/ui/users_controller.rb index 365618dc..09e4ee29 100644 --- a/app/controllers/ui/users_controller.rb +++ b/app/controllers/ui/users_controller.rb @@ -6,11 +6,21 @@ def index end def new + if current_user + flash[:alert] = I18n.t(:new_user_not_allowed_for_logged_in_users) + redirect_to ui_users_path + return + end @title = I18n.t(:new_user_title) @user = User.new end def create + if current_user + flash[:alert] = I18n.t(:new_user_not_allowed_for_logged_in_users) + redirect_to ui_users_path + return + end @user = User.new(params.require(:user).permit( :username, :email, diff --git a/config/locales/views/users/en.yml b/config/locales/views/users/en.yml index 98a5e7ee..335dfdf3 100644 --- a/config/locales/views/users/en.yml +++ b/config/locales/views/users/en.yml @@ -5,3 +5,4 @@ en: new_user_failure: "Some errors prevented us from creating your account. Please check below and try again!" new_user_login_heading: "Already have an account?" new_user_login_link: "Log in" + new_user_not_allowed_for_logged_in_users: "Sorry, logged in users can't create new accounts. Please log out and try again."