Files
danbooru/app/controllers/user_name_change_requests_controller.rb
evazion 6ca007ee1f Fix #4670: Replace RequestStore with AS::CurrentAttributes.
This also requires replacing CurrentUser.name with CurrentUser.user.name
because the `name` method had a conflict with CurrentAttributes.
2021-01-16 12:43:20 -06:00

26 lines
877 B
Ruby

class UserNameChangeRequestsController < ApplicationController
respond_to :html, :json, :xml
def new
@change_request = authorize UserNameChangeRequest.new(permitted_attributes(UserNameChangeRequest))
respond_with(@change_request)
end
def create
@change_request = authorize UserNameChangeRequest.new(user: CurrentUser.user, original_name: CurrentUser.user.name)
@change_request.update(permitted_attributes(@change_request))
flash[:notice] = "Your name has been changed" if @change_request.valid?
respond_with(@change_request, location: profile_path)
end
def show
@change_request = authorize UserNameChangeRequest.find(params[:id])
respond_with(@change_request)
end
def index
@change_requests = authorize UserNameChangeRequest.visible(CurrentUser.user).paginated_search(params)
respond_with(@change_requests)
end
end