Simplify route_authorization
This commit is contained in:
parent
bf9f3b40df
commit
47962ef795
4 changed files with 10 additions and 4 deletions
|
@ -59,7 +59,7 @@ class Users::CarteController < UsersController
|
|||
|
||||
def self.route_authorization
|
||||
{
|
||||
states: [:brouillon, :en_construction],
|
||||
states: [Dossier.states.fetch(:brouillon), Dossier.states.fetch(:en_construction)],
|
||||
api_carto: true
|
||||
}
|
||||
end
|
||||
|
|
|
@ -149,7 +149,7 @@ class Users::DossiersController < UsersController
|
|||
|
||||
def self.route_authorization
|
||||
{
|
||||
states: [:brouillon]
|
||||
states: [Dossier.states.fetch(:brouillon)]
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,13 @@ class Users::RecapitulatifController < UsersController
|
|||
|
||||
def self.route_authorization
|
||||
{
|
||||
states: [:en_construction, :en_instruction, :sans_suite, :accepte, :refuse]
|
||||
states: [
|
||||
Dossier.states.fetch(:en_construction),
|
||||
Dossier.states.fetch(:en_instruction),
|
||||
Dossier.states.fetch(:sans_suite),
|
||||
Dossier.states.fetch(:accepte),
|
||||
Dossier.states.fetch(:refuse)
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class UserRoutesAuthorizationService
|
|||
def self.authorized_route?(controller, dossier)
|
||||
auth = controller.route_authorization
|
||||
|
||||
auth[:states].include?(dossier.state.to_sym) &&
|
||||
auth[:states].include?(dossier.state) &&
|
||||
(auth[:api_carto].nil? ? true : auth[:api_carto] == dossier.procedure.use_api_carto)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue