Files
danbooru/app/controllers/user_name_change_requests_controller.rb
evazion 525acd17a5 users: lock out users with invalid names until they change their name.
Forcibly redirect users to the name change page if their name is
invalid. This means user with invalid names can't do anything or view
any pages until they change their name. API requests are still allowed.
2022-03-07 04:36:12 -06:00

30 lines
957 B
Ruby

# frozen_string_literal: true
class UserNameChangeRequestsController < ApplicationController
respond_to :html, :json, :xml
skip_before_action :redirect_if_name_invalid?
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