- Move files into components (article) - Split articles routes - Refactoring for remove ktor-voter (ArticleVoter) - Remove mutability - Move DataConversion to separate file (Converter.kt) - Add Schemas for Articles routes - Fix SQL Query for Workgroup roles - rename container_name in docker-compose
27 lines
704 B
Kotlin
27 lines
704 B
Kotlin
package fr.dcproject.security.voter
|
|
|
|
import fr.dcproject.entity.OpinionChoice
|
|
import fr.dcproject.voter.NoSubjectDefinedException
|
|
import fr.ktorVoter.*
|
|
import io.ktor.application.*
|
|
|
|
class OpinionChoiceVoter : Voter<ApplicationCall> {
|
|
enum class Action : ActionI {
|
|
VIEW
|
|
}
|
|
|
|
override fun invoke(action: Any, context: ApplicationCall, subject: Any?): VoterResponseI {
|
|
if (!((action is Action)
|
|
&& (subject is OpinionChoice?))) return abstain()
|
|
|
|
if (action == Action.VIEW) {
|
|
if (subject is OpinionChoice) {
|
|
return granted()
|
|
}
|
|
throw NoSubjectDefinedException(action)
|
|
}
|
|
|
|
return abstain()
|
|
}
|
|
}
|