2016-02-08 18:16:18 +01:00
|
|
|
class Users::Dossiers::InvitesController < UsersController
|
2016-02-22 10:34:25 +01:00
|
|
|
def authenticate_user!
|
|
|
|
session["user_return_to"] = request.fullpath
|
2018-09-18 16:18:58 +02:00
|
|
|
|
|
|
|
if params[:email].present? && User.find_by(email: params[:email]).nil?
|
2018-09-18 16:54:37 +02:00
|
|
|
return redirect_to new_user_registration_path(user: { email: params[:email] })
|
2018-09-18 16:18:58 +02:00
|
|
|
end
|
2016-02-22 10:34:25 +01:00
|
|
|
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2016-02-08 18:16:18 +01:00
|
|
|
def show
|
2017-01-04 18:03:03 +01:00
|
|
|
@facade = InviteDossierFacades.new params[:id].to_i, current_user.email
|
2016-02-08 18:16:18 +01:00
|
|
|
|
2018-08-01 17:27:50 +02:00
|
|
|
if @facade.dossier.brouillon?
|
2018-09-06 09:09:23 +02:00
|
|
|
redirect_to brouillon_dossier_path(@facade.dossier)
|
2018-08-01 17:27:50 +02:00
|
|
|
else
|
2018-10-02 12:23:53 +02:00
|
|
|
return redirect_to dossier_path(@facade.dossier)
|
2018-08-01 17:27:50 +02:00
|
|
|
end
|
2016-02-08 18:16:18 +01:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
flash.alert = t('errors.messages.dossier_not_found')
|
2018-06-27 14:47:02 +02:00
|
|
|
redirect_to url_for dossiers_path
|
2016-02-08 18:16:18 +01:00
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|