demarches-normaliennes/app/controllers/new_user/dossiers_controller.rb

28 lines
582 B
Ruby
Raw Normal View History

module NewUser
class DossiersController < UserController
before_action :ensure_ownership!
def attestation
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
def identite
@dossier = dossier
@user = current_user
end
private
def dossier
Dossier.find(params[:id] || params[:dossier_id])
end
def ensure_ownership!
if dossier.user != current_user
flash[:alert] = "Vous n'avez pas accès à ce dossier"
redirect_to root_path
end
end
end
end