Files
danbooru/app/controllers/user_name_change_requests_controller.rb
evazion 565a6572a7 pundit: convert user name change requests to pundit.
Fix discrepancy between index action and show action. The index
action allowed members to see name changes for undeleted users, but the
show action didn't.
2020-03-20 18:03:00 -05:00

26 lines
914 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.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).order("id desc").paginate(params[:page], :limit => params[:limit])
respond_with(@change_requests)
end
end