Refactors Articles and Voter
- 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
This commit is contained in:
@@ -1,27 +1,26 @@
|
||||
package fr.dcproject.security.voter
|
||||
|
||||
import fr.dcproject.entity.OpinionChoice
|
||||
import fr.ktorVoter.ActionI
|
||||
import fr.ktorVoter.Vote
|
||||
import fr.ktorVoter.Voter
|
||||
import io.ktor.application.ApplicationCall
|
||||
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?): Vote {
|
||||
override fun invoke(action: Any, context: ApplicationCall, subject: Any?): VoterResponseI {
|
||||
if (!((action is Action)
|
||||
&& (subject is OpinionChoice?))) return Vote.ABSTAIN
|
||||
&& (subject is OpinionChoice?))) return abstain()
|
||||
|
||||
if (action == Action.VIEW) {
|
||||
if (subject is OpinionChoice) {
|
||||
return Vote.GRANTED
|
||||
return granted()
|
||||
}
|
||||
return Vote.DENIED
|
||||
throw NoSubjectDefinedException(action)
|
||||
}
|
||||
|
||||
return Vote.ABSTAIN
|
||||
return abstain()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user