users: fix bug in changing usernames.

Fix the change username page not showing the user's current name when a mod is changing a user's name.
This commit is contained in:
evazion
2022-10-02 02:35:08 -05:00
parent 99846b7e3d
commit 906316c48e
2 changed files with 4 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ class UserNameChangeRequestsController < ApplicationController
skip_before_action :redirect_if_name_invalid?
def new
user = User.find_by_name(params[:id]) || CurrentUser.user
user = params[:id].present? ? User.find(params[:id]) : CurrentUser.user
@change_request = authorize UserNameChangeRequest.new(user: user, **permitted_attributes(UserNameChangeRequest))
respond_with(@change_request)
end

View File

@@ -6,13 +6,13 @@
<h1>Change Name</h1>
<% end %>
<% if CurrentUser.user.name_invalid? %>
<% if @change_request.user.name_invalid? %>
<p> Your current username is invalid. You must change your username to continue
using <%= Danbooru.config.canonical_app_name %>.</p>
<p>
Current name: <b><%= CurrentUser.user.name %></b>.<br>
Error: <%= CurrentUser.user.name_errors.full_messages.join(". ").html_safe %>.
Current name: <b><%= @change_request.user.name %></b>.<br>
Error: <%= @change_request.user.name_errors.full_messages.join(". ").html_safe %>.
</p>
<% end %>