Files
danbooru/app/controllers/maintenance/user/deletions_controller.rb
evazion 8134e92457 user deletions: fix error when given incorrect password.
Use validations instead of raising an exception when the password is
incorrect so that the controller can display errors sensibly.

Also fix users being logged out even when the deletion attempt failed
due to an incorrect password.
2020-04-03 23:44:23 -05:00

25 lines
638 B
Ruby

module Maintenance
module User
class DeletionsController < ApplicationController
respond_to :html, :json, :xml
def show
end
def destroy
deletion = UserDeletion.new(CurrentUser.user, params.dig(:user, :password))
deletion.delete!
if deletion.errors.none?
session.delete(:user_id)
flash[:notice] = "Your account has been deactivated"
respond_with(deletion, location: posts_path)
else
flash[:notice] = deletion.errors.full_messages.join("; ")
redirect_to maintenance_user_deletion_path
end
end
end
end
end