diff --git a/app/controllers/users/dossiers/invites_controller.rb b/app/controllers/users/dossiers/invites_controller.rb index c766a8ce0..7ffdcd20b 100644 --- a/app/controllers/users/dossiers/invites_controller.rb +++ b/app/controllers/users/dossiers/invites_controller.rb @@ -1,21 +1,23 @@ class Users::Dossiers::InvitesController < UsersController def authenticate_user! session["user_return_to"] = request.fullpath + email = params[:email] - if params[:email].present? && User.find_by(email: params[:email]).nil? - return redirect_to new_user_registration_path(user: { email: params[:email] }) + if email.present? && User.find_by(email: email).nil? + redirect_to new_user_registration_path(user: { email: email }) + else + super end - - super end def show - @facade = InviteDossierFacades.new params[:id].to_i, current_user.email + invite = Invite.where(email: current_user.email, id: params[:id].to_i).first! + dossier = invite.dossier - if @facade.dossier.brouillon? - redirect_to brouillon_dossier_path(@facade.dossier) + if dossier.brouillon? + redirect_to brouillon_dossier_path(dossier) else - return redirect_to dossier_path(@facade.dossier) + redirect_to dossier_path(dossier) end rescue ActiveRecord::RecordNotFound flash.alert = t('errors.messages.dossier_not_found') diff --git a/app/facades/invite_dossier_facades.rb b/app/facades/invite_dossier_facades.rb deleted file mode 100644 index 138e0e131..000000000 --- a/app/facades/invite_dossier_facades.rb +++ /dev/null @@ -1,6 +0,0 @@ -class InviteDossierFacades < DossierFacades - # TODO rechercher en fonction de la personne/email - def initialize(id, email) - @dossier = Invite.where(email: email, id: id).first!.dossier - end -end diff --git a/lib/tasks/deployment/20181010102500_remove_invite_gestionnaires.rake b/lib/tasks/deployment/20181010102500_remove_invite_gestionnaires.rake new file mode 100644 index 000000000..fbbce4a15 --- /dev/null +++ b/lib/tasks/deployment/20181010102500_remove_invite_gestionnaires.rake @@ -0,0 +1,10 @@ +namespace :after_party do + desc 'Deployment task: remove_invite_gestionnaires' + task remove_invite_gestionnaires: :environment do + InviteGestionnaire.destroy_all + + # Update task as completed. If you remove the line below, the task will + # run with every deploy (or every time you call after_party:run). + AfterParty::TaskRecord.create version: '20181010102500' + end +end