demarches-normaliennes/app/controllers/users/dossiers/invites_controller.rb
2018-09-24 17:05:27 +02:00

28 lines
801 B
Ruby

class Users::Dossiers::InvitesController < UsersController
def authenticate_user!
session["user_return_to"] = request.fullpath
if params[:email].present? && User.find_by(email: params[:email]).nil?
return redirect_to new_user_registration_path(user: { email: params[:email] })
end
super
end
def show
@facade = InviteDossierFacades.new params[:id].to_i, current_user.email
if Flipflop.new_dossier_details?
return redirect_to dossier_path(@facade.dossier)
end
if @facade.dossier.brouillon?
redirect_to brouillon_dossier_path(@facade.dossier)
else
render 'users/recapitulatif/show'
end
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for dossiers_path
end
end