Skip to content

Commit

Permalink
logged in users can't create new users
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Nov 21, 2024
1 parent 360c1bd commit 8a506df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/controllers/ui/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions config/locales/views/users/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."

0 comments on commit 8a506df

Please sign in to comment.