commencer: fix redirection with invalid path
This commit is contained in:
parent
fb19b856c5
commit
41ad89d8ac
3 changed files with 53 additions and 14 deletions
|
@ -4,38 +4,39 @@ module Users
|
|||
|
||||
def commencer
|
||||
@procedure = Procedure.publiees.find_by(path: params[:path])
|
||||
|
||||
if @procedure.blank?
|
||||
flash.alert = "La démarche est inconnue, ou la création de nouveaux dossiers pour cette démarche est terminée."
|
||||
return redirect_to root_path
|
||||
end
|
||||
return procedure_not_found if @procedure.blank?
|
||||
|
||||
render 'commencer/show'
|
||||
end
|
||||
|
||||
def commencer_test
|
||||
@procedure = Procedure.brouillons.find_by(path: params[:path])
|
||||
|
||||
if @procedure.blank?
|
||||
flash.alert = "La démarche est inconnue, ou cette démarche n’est maintenant plus en test."
|
||||
return redirect_to root_path
|
||||
end
|
||||
return procedure_not_found if @procedure.blank?
|
||||
|
||||
render 'commencer/show'
|
||||
end
|
||||
|
||||
def sign_in
|
||||
store_user_location!
|
||||
@procedure = Procedure.find_by(path: params[:path])
|
||||
return procedure_not_found if @procedure.blank?
|
||||
|
||||
store_user_location!(@procedure)
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
|
||||
def sign_up
|
||||
store_user_location!
|
||||
@procedure = Procedure.find_by(path: params[:path])
|
||||
return procedure_not_found if @procedure.blank?
|
||||
|
||||
store_user_location!(@procedure)
|
||||
redirect_to new_user_registration_path
|
||||
end
|
||||
|
||||
def france_connect
|
||||
store_user_location!
|
||||
@procedure = Procedure.find_by(path: params[:path])
|
||||
return procedure_not_found if @procedure.blank?
|
||||
|
||||
store_user_location!(@procedure)
|
||||
redirect_to france_connect_particulier_path
|
||||
end
|
||||
|
||||
|
@ -45,8 +46,21 @@ module Users
|
|||
|
||||
private
|
||||
|
||||
def store_user_location!
|
||||
def procedure_not_found
|
||||
procedure = Procedure.find_by(path: params[:path])
|
||||
|
||||
if procedure&.archivee?
|
||||
flash.alert = t('errors.messages.procedure_archived')
|
||||
elsif procedure&.publiee?
|
||||
flash.alert = t('errors.messages.procedure_not_draft')
|
||||
else
|
||||
flash.alert = t('errors.messages.procedure_not_found')
|
||||
end
|
||||
|
||||
return redirect_to root_path
|
||||
end
|
||||
|
||||
def store_user_location!(procedure)
|
||||
store_location_for(:user, helpers.procedure_lien(procedure))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue