discourse/app/controllers/draft_controller.rb
Sam 41986cdb2f Refactor requires login logic, reduce duplicate code
This also corrects the positioning in the chain of the check
and removes misuse of prepend_before_action
2018-02-01 15:17:59 +11:00

22 lines
581 B
Ruby

class DraftController < ApplicationController
requires_login
skip_before_action :check_xhr, :preload_json
def show
seq = params[:sequence] || DraftSequence.current(current_user, params[:draft_key])
render json: { draft: Draft.get(current_user, params[:draft_key], seq), draft_sequence: seq }
end
def update
Draft.set(current_user, params[:draft_key], params[:sequence].to_i, params[:data])
render json: success_json
end
def destroy
Draft.clear(current_user, params[:draft_key], params[:sequence].to_i)
render json: success_json
end
end