diff --git a/src/main/kotlin/fr/dcproject/security/voter/ArticleVoter.kt b/src/main/kotlin/fr/dcproject/security/voter/ArticleVoter.kt index 60e4da1..1d5ad40 100644 --- a/src/main/kotlin/fr/dcproject/security/voter/ArticleVoter.kt +++ b/src/main/kotlin/fr/dcproject/security/voter/ArticleVoter.kt @@ -1,8 +1,8 @@ package fr.dcproject.security.voter -import fr.dcproject.entity.Article import fr.dcproject.entity.User import io.ktor.application.ApplicationCall +import fr.dcproject.entity.Article as ArticleEntity class ArticleVoter: Voter { enum class Action: ActionI { @@ -34,14 +34,18 @@ class ArticleVoter: Voter { return Vote.GRANTED } - if (action == Action.DELETE && user is User && subject is Article && subject.createdBy?.userId == user.id) { + if (action == Action.DELETE && user is User && subject is ArticleEntity && subject.createdBy?.userId == user.id) { return Vote.GRANTED } - if (action == Action.UPDATE && user is User && subject is Article && subject.createdBy?.userId == user.id) { + if (action == Action.UPDATE && user is User && subject is ArticleEntity && subject.createdBy?.userId == user.id) { return Vote.GRANTED } + if (action is Action) { + return Vote.DENIED + } + return Vote.ABSTAIN } } diff --git a/src/main/kotlin/fr/dcproject/security/voter/CitizenVoter.kt b/src/main/kotlin/fr/dcproject/security/voter/CitizenVoter.kt index ebc062a..7d2a264 100644 --- a/src/main/kotlin/fr/dcproject/security/voter/CitizenVoter.kt +++ b/src/main/kotlin/fr/dcproject/security/voter/CitizenVoter.kt @@ -37,6 +37,10 @@ class CitizenVoter: Voter { return Vote.GRANTED } + if (action is Action) { + return Vote.DENIED + } + return Vote.ABSTAIN } } diff --git a/src/main/kotlin/fr/dcproject/security/voter/CommentVoter.kt b/src/main/kotlin/fr/dcproject/security/voter/CommentVoter.kt index b4011d9..924bff6 100644 --- a/src/main/kotlin/fr/dcproject/security/voter/CommentVoter.kt +++ b/src/main/kotlin/fr/dcproject/security/voter/CommentVoter.kt @@ -33,6 +33,10 @@ class CommentVoter: Voter { return Vote.DENIED } + if (action is Action) { + return Vote.DENIED + } + return Vote.ABSTAIN } }