Skip to content

Commit 1bd5e67

Browse files
committed
Form création procédure - Refactoring vérification de droits
ref #1258
1 parent 5b61f7a commit 1bd5e67

File tree

1 file changed

+12
-6
lines changed
  • nuxt/pages/collectivites/_collectiviteId/procedures

1 file changed

+12
-6
lines changed

nuxt/pages/collectivites/_collectiviteId/procedures/add.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ export default {
3434
const collectivites = await this.$nuxt3api(`/api/geo/search/collectivites?code=${this.$route.params.collectiviteId}&populate=true`)
3535
this.collectivite = collectivites[0]
3636
37-
if (this.$user.profile?.side === 'etat') {
38-
if (this.$user.profile?.departement !== this.collectivite.departementCode) {
39-
this.$router.push(`/collectivites/${this.$route.params.collectiviteId}`)
40-
}
41-
} else if (this.$user.profile?.collectivite_id !== this.collectivite.code &&
42-
this.$user.profile?.collectivite_id !== this.collectivite.intercommunaliteCode) {
37+
const isSideEtatWithMatchingDepartement = this.$user.profile.side === 'etat' &&
38+
this.$user.profile.departement === this.collectivite.departementCode
39+
const isSideCollectiviteWithMatchingCollectivite = this.$user.profile.side === 'collectivite' &&
40+
(this.$user.profile.collectivite_id === this.collectivite.code ||
41+
this.$user.profile.collectivite_id === this.collectivite.intercommunaliteCode)
42+
43+
const canCreateProcedure =
44+
isSideEtatWithMatchingDepartement ||
45+
isSideCollectiviteWithMatchingCollectivite
46+
47+
if (!canCreateProcedure) {
48+
console.warn('Pas assez de droits pour créer une procédure sur ce périmètre')
4349
this.$router.push(`/collectivites/${this.$route.params.collectiviteId}`)
4450
}
4551
}

0 commit comments

Comments
 (0)