demarches-normaliennes/app/controllers/users/dossiers/invites_controller.rb

27 lines
722 B
Ruby
Raw Normal View History

class Users::Dossiers::InvitesController < UsersController
def authenticate_user!
session["user_return_to"] = request.fullpath
2018-10-10 10:32:01 +02:00
email = params[:email]
2018-10-10 10:32:01 +02:00
if email.present? && User.find_by(email: email).nil?
2018-10-10 10:32:59 +02:00
redirect_to new_user_registration_path(user: { email: email })
else
super
end
end
def show
2018-10-10 08:55:39 +02:00
invite = Invite.where(email: current_user.email, id: params[:id].to_i).first!
dossier = invite.dossier
2018-10-10 08:55:39 +02:00
if dossier.brouillon?
redirect_to brouillon_dossier_path(dossier)
else
redirect_to dossier_path(dossier)
end
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
redirect_to url_for dossiers_path
end
2017-04-04 15:27:04 +02:00
end