add content
This commit is contained in:
@@ -5,9 +5,8 @@ import dev.inmo.postssystem.features.auth.server.tokens.AuthTokensService
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.users.common.User
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.micro_utils.ktor.server.*
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.*
|
||||
import dev.inmo.micro_utils.ktor.server.unianswer
|
||||
import dev.inmo.micro_utils.ktor.server.uniload
|
||||
import io.ktor.application.*
|
||||
import io.ktor.auth.*
|
||||
import io.ktor.http.HttpStatusCode
|
||||
@@ -25,81 +24,84 @@ fun User.principal() = AuthUserPrincipal(this)
|
||||
|
||||
class AuthenticationRoutingConfigurator(
|
||||
private val authFeature: AuthFeature,
|
||||
private val authTokensService: AuthTokensService
|
||||
private val authTokensService: AuthTokensService,
|
||||
private val unifiedRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element, ApplicationAuthenticationConfigurator.Element {
|
||||
override fun Route.invoke() {
|
||||
route(authRootPathPart) {
|
||||
post(authAuthPathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
it.printStackTrace()
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
)
|
||||
}
|
||||
) {
|
||||
val creds = call.uniload(AuthCreds.serializer())
|
||||
|
||||
val tokenInfo = authFeature.auth(creds)
|
||||
|
||||
if (tokenInfo == null) {
|
||||
if (call.response.status() == null) {
|
||||
call.respond(HttpStatusCode.Forbidden)
|
||||
unifiedRouter.apply {
|
||||
route(authRootPathPart) {
|
||||
post(authAuthPathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
it.printStackTrace()
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
)
|
||||
}
|
||||
) {
|
||||
val creds = uniload(AuthCreds.serializer())
|
||||
|
||||
val tokenInfo = authFeature.auth(creds)
|
||||
|
||||
if (tokenInfo == null) {
|
||||
if (call.response.status() == null) {
|
||||
call.respond(HttpStatusCode.Forbidden)
|
||||
}
|
||||
} else {
|
||||
call.sessions.set(tokenSessionKey, tokenInfo.token)
|
||||
unianswer(
|
||||
AuthTokenInfo.serializer().nullable,
|
||||
tokenInfo
|
||||
)
|
||||
}
|
||||
} else {
|
||||
call.sessions.set(tokenSessionKey, tokenInfo.token)
|
||||
call.unianswer(
|
||||
AuthTokenInfo.serializer().nullable,
|
||||
tokenInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
post(authRefreshPathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
)
|
||||
}
|
||||
) {
|
||||
val refreshToken = call.uniload(RefreshToken.serializer())
|
||||
|
||||
val tokenInfo = authFeature.refresh(refreshToken)
|
||||
|
||||
if (tokenInfo == null) {
|
||||
if (call.response.status() == null) {
|
||||
call.respond(HttpStatusCode.Forbidden)
|
||||
post(authRefreshPathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
)
|
||||
}
|
||||
) {
|
||||
val refreshToken = uniload(RefreshToken.serializer())
|
||||
|
||||
val tokenInfo = authFeature.refresh(refreshToken)
|
||||
|
||||
if (tokenInfo == null) {
|
||||
if (call.response.status() == null) {
|
||||
call.respond(HttpStatusCode.Forbidden)
|
||||
}
|
||||
} else {
|
||||
call.sessions.set(tokenSessionKey, tokenInfo.token)
|
||||
unianswer(
|
||||
AuthTokenInfo.serializer().nullable,
|
||||
tokenInfo
|
||||
)
|
||||
}
|
||||
} else {
|
||||
call.sessions.set(tokenSessionKey, tokenInfo.token)
|
||||
call.unianswer(
|
||||
AuthTokenInfo.serializer().nullable,
|
||||
tokenInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
post(authGetMePathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
post(authGetMePathPart) {
|
||||
safely(
|
||||
{
|
||||
// TODO:: add error info
|
||||
call.respond(
|
||||
HttpStatusCode.InternalServerError,
|
||||
"Something went wrong"
|
||||
)
|
||||
}
|
||||
) {
|
||||
unianswer(
|
||||
User.serializer().nullable,
|
||||
authFeature.getMe(
|
||||
uniload(AuthToken.serializer())
|
||||
)
|
||||
)
|
||||
}
|
||||
) {
|
||||
call.unianswer(
|
||||
User.serializer().nullable,
|
||||
authFeature.getMe(
|
||||
call.uniload(AuthToken.serializer())
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import org.koin.core.definition.Definition
|
||||
import org.koin.core.instance.InstanceFactory
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
/**
|
||||
* Will be useful in case you need to declare some singles with one type several types, but need to separate them and do
|
||||
* not care about how :)
|
||||
*/
|
||||
inline fun <reified T : Any> Module.singleWithRandomQualifier(
|
||||
createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>
|
||||
) = single(uuid4().toString(), createdAtStart, definition)
|
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import org.koin.core.definition.Definition
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
inline fun <reified T : Any> Module.single(
|
||||
qualifier: String,
|
||||
createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>
|
||||
) = single(StringQualifier(qualifier), createdAtStart, definition)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.postssystem.features.common.common
|
||||
|
||||
import kotlinx.serialization.modules.SerializersModuleBuilder
|
||||
|
||||
class SerializersModuleConfigurator(
|
||||
private val elements: List<Element>
|
||||
) {
|
||||
fun interface Element {
|
||||
operator fun SerializersModuleBuilder.invoke()
|
||||
}
|
||||
operator fun SerializersModuleBuilder.invoke() {
|
||||
elements.forEach { it.apply { invoke() } }
|
||||
}
|
||||
}
|
@@ -11,6 +11,6 @@ inline fun <reified T : Any> Module.singleWithBinds(
|
||||
qualifier: Qualifier? = null,
|
||||
createdAtStart: Boolean = false,
|
||||
noinline definition: Definition<T>
|
||||
): Pair<Module, InstanceFactory<*>> {
|
||||
return single(qualifier, createdAtStart, definition) binds (T::class.allSuperclasses.toTypedArray())
|
||||
): Pair<Module, InstanceFactory<T>> {
|
||||
return single(qualifier, createdAtStart, definition)
|
||||
}
|
||||
|
18
features/content/client/build.gradle
Normal file
18
features/content/client/build.gradle
Normal file
@@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":postssystem.features.content.common")
|
||||
api project(":postssystem.features.common.client")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
features/content/client/src/main/AndroidManifest.xml
Normal file
1
features/content/client/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.content.client"/>
|
17
features/content/common/build.gradle
Normal file
17
features/content/common/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":postssystem.features.common.common")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
typealias ContentId = String
|
||||
|
||||
/**
|
||||
* Content which is planned to be registered in database
|
||||
*
|
||||
* @see ContentSerializersModuleConfigurator.Element
|
||||
* @see ContentSerializersModuleConfigurator
|
||||
*/
|
||||
interface Content
|
||||
|
||||
/**
|
||||
* Content which is already registered in database. Using its [id] you can retrieve all known
|
||||
* [dev.inmo.postssystem.core.post.RegisteredPost]s by using
|
||||
* [dev.inmo.postssystem.core.post.repo.ReadPostsRepo.getPostsByContent]
|
||||
*/
|
||||
@Serializable
|
||||
data class RegisteredContent(
|
||||
val id: ContentId,
|
||||
val content: Content
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.SerializersModuleConfigurator
|
||||
import kotlinx.serialization.modules.*
|
||||
|
||||
class ContentSerializersModuleConfigurator(
|
||||
private val subconfigurators: List<Element>
|
||||
) : SerializersModuleConfigurator.Element {
|
||||
fun interface Element {
|
||||
operator fun PolymorphicModuleBuilder<Content>.invoke()
|
||||
}
|
||||
|
||||
override fun SerializersModuleBuilder.invoke() {
|
||||
polymorphic(Content::class) {
|
||||
subconfigurators.forEach { it.apply { invoke() } }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.modules.PolymorphicModuleBuilder
|
||||
|
||||
/**
|
||||
* That is a content which in fact just a link to another content. It would be useful in case when user wish to reuse
|
||||
* some content
|
||||
*/
|
||||
@Serializable
|
||||
data class OtherContentLinkContent(
|
||||
val otherId: ContentId
|
||||
) : Content
|
||||
|
||||
object OtherContentSerializerModuleConfigurator : ContentSerializersModuleConfigurator.Element {
|
||||
override fun PolymorphicModuleBuilder<Content>.invoke() {
|
||||
subclass(OtherContentLinkContent::class, OtherContentLinkContent.serializer())
|
||||
}
|
||||
}
|
1
features/content/common/src/main/AndroidManifest.xml
Normal file
1
features/content/common/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.content.common"/>
|
17
features/content/server/build.gradle
Normal file
17
features/content/server/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
}
|
||||
|
||||
apply from: "$mppJavaProjectPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api project(":postssystem.features.content.common")
|
||||
api project(":postssystem.features.common.server")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,9 +14,10 @@ import kotlinx.serialization.builtins.nullable
|
||||
|
||||
class FilesRoutingConfigurator(
|
||||
private val filesStorage: FilesStorage,
|
||||
private val writeFilesStorage: WriteFilesStorage?
|
||||
private val writeFilesStorage: WriteFilesStorage?,
|
||||
private val unifierRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
constructor(fullFilesStorage: FullFilesStorage) : this(fullFilesStorage, fullFilesStorage)
|
||||
constructor(fullFilesStorage: FullFilesStorage, unifierRouter: UnifiedRouter) : this(fullFilesStorage, fullFilesStorage, unifierRouter)
|
||||
|
||||
override fun Route.invoke() {
|
||||
authenticate {
|
||||
@@ -25,7 +26,8 @@ class FilesRoutingConfigurator(
|
||||
filesStorage,
|
||||
MetaFileInfoStorageWrapper.serializer(),
|
||||
MetaFileInfoStorageWrapper.serializer().nullable,
|
||||
FileId.serializer()
|
||||
FileId.serializer(),
|
||||
unifierRouter
|
||||
)
|
||||
writeFilesStorage ?.let {
|
||||
configureWriteStandardCrudRepoRoutes(
|
||||
@@ -33,23 +35,27 @@ class FilesRoutingConfigurator(
|
||||
FullFileInfoStorageWrapper.serializer(),
|
||||
FullFileInfoStorageWrapper.serializer().nullable,
|
||||
FullFileInfo.serializer(),
|
||||
FileId.serializer()
|
||||
FileId.serializer(),
|
||||
unifierRouter
|
||||
)
|
||||
}
|
||||
post(filesGetFilesPathPart) {
|
||||
call.respondBytes(
|
||||
filesStorage.getBytes(
|
||||
call.uniload(FileId.serializer())
|
||||
|
||||
unifierRouter.apply {
|
||||
post(filesGetFilesPathPart) {
|
||||
call.respondBytes(
|
||||
filesStorage.getBytes(
|
||||
uniload(FileId.serializer())
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
get(filesGetFullFileInfoPathPart) {
|
||||
call.unianswer(
|
||||
FullFileInfoStorageWrapper.serializer().nullable,
|
||||
filesStorage.getFullFileInfo(
|
||||
call.decodeUrlQueryValueOrSendError(filesFileIdParameter, FileId.serializer()) ?: return@get
|
||||
}
|
||||
get(filesGetFullFileInfoPathPart) {
|
||||
unianswer(
|
||||
FullFileInfoStorageWrapper.serializer().nullable,
|
||||
filesStorage.getFullFileInfo(
|
||||
decodeUrlQueryValueOrSendError(filesFileIdParameter, FileId.serializer()) ?: return@get
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.postssystem.features.roles.manager.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.UnifiedRouter
|
||||
import dev.inmo.postssystem.features.roles.common.UsersRolesStorage
|
||||
import dev.inmo.postssystem.features.roles.manager.common.RolesManagerRole
|
||||
import dev.inmo.postssystem.features.roles.manager.common.RolesManagerRoleSerializer
|
||||
@@ -7,9 +8,11 @@ import dev.inmo.postssystem.features.roles.server.UsersRolesStorageWriteServerRo
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||
|
||||
class RolesManagerUsersRolesStorageServerRoutesConfigurator(
|
||||
storage: UsersRolesStorage<RolesManagerRole>
|
||||
storage: UsersRolesStorage<RolesManagerRole>,
|
||||
unifiedRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element by UsersRolesStorageWriteServerRoutesConfigurator(
|
||||
storage,
|
||||
RolesManagerRoleSerializer,
|
||||
RolesManagerRolesChecker.key
|
||||
RolesManagerRolesChecker.key,
|
||||
unifiedRouter = unifiedRouter
|
||||
)
|
||||
|
@@ -15,7 +15,7 @@ import io.ktor.response.respond
|
||||
class UsersRolesAuthenticationConfigurator<T : UserRole>(
|
||||
private val usersRolesStorage: UsersRolesStorage<T>,
|
||||
private val authTokensService: AuthTokensService,
|
||||
private val rolesCheckers: List<RolesChecker<T>>
|
||||
private val rolesCheckers: List<RolesChecker<T>>,
|
||||
) : ApplicationAuthenticationConfigurator.Element {
|
||||
override fun Authentication.Configuration.invoke() {
|
||||
rolesCheckers.forEach { checker ->
|
||||
|
@@ -13,59 +13,61 @@ import kotlinx.serialization.builtins.serializer
|
||||
|
||||
class UsersRolesStorageReadServerRoutesConfigurator<T : UserRole>(
|
||||
private val storage: ReadUsersRolesStorage<T>,
|
||||
private val serializer: KSerializer<T>
|
||||
private val serializer: KSerializer<T>,
|
||||
private val unifiedRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
private val userRolesSerializer = ListSerializer(serializer)
|
||||
override fun Route.invoke() {
|
||||
authenticate {
|
||||
route(usersRolesRootPathPart) {
|
||||
get(usersRolesGetUsersPathPart) {
|
||||
val userRole = call.decodeUrlQueryValueOrSendError(usersRolesUserRoleQueryParameterName, serializer)
|
||||
?: return@get
|
||||
call.unianswer(
|
||||
UsersIdsSerializer,
|
||||
storage.getUsers(userRole)
|
||||
)
|
||||
}
|
||||
|
||||
get(usersRolesGetRolesPathPart) {
|
||||
val userId =
|
||||
call.decodeUrlQueryValueOrSendError(usersRolesUserIdQueryParameterName, UserId.serializer())
|
||||
unifiedRouter.apply {
|
||||
authenticate {
|
||||
route(usersRolesRootPathPart) {
|
||||
get(usersRolesGetUsersPathPart) {
|
||||
val userRole = decodeUrlQueryValueOrSendError(usersRolesUserRoleQueryParameterName, serializer)
|
||||
?: return@get
|
||||
call.unianswer(
|
||||
userRolesSerializer,
|
||||
storage.getRoles(userId)
|
||||
)
|
||||
}
|
||||
unianswer(
|
||||
UsersIdsSerializer,
|
||||
storage.getUsers(userRole)
|
||||
)
|
||||
}
|
||||
|
||||
get(usersRolesContainsPathPart) {
|
||||
val userId = call.decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserIdQueryParameterName,
|
||||
UserId.serializer()
|
||||
) ?: return@get
|
||||
val userRole = call.decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserRoleQueryParameterName,
|
||||
serializer
|
||||
) ?: return@get
|
||||
call.unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.contains(userId, userRole)
|
||||
)
|
||||
}
|
||||
get(usersRolesGetRolesPathPart) {
|
||||
val userId = decodeUrlQueryValueOrSendError(usersRolesUserIdQueryParameterName, UserId.serializer())
|
||||
?: return@get
|
||||
unianswer(
|
||||
userRolesSerializer,
|
||||
storage.getRoles(userId)
|
||||
)
|
||||
}
|
||||
|
||||
get(usersRolesContainsAnyPathPart) {
|
||||
val userId = call.decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserIdQueryParameterName,
|
||||
UserId.serializer()
|
||||
) ?: return@get
|
||||
val userRoles = call.decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserRoleQueryParameterName,
|
||||
userRolesSerializer
|
||||
) ?: return@get
|
||||
call.unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.containsAny(userId, userRoles)
|
||||
)
|
||||
get(usersRolesContainsPathPart) {
|
||||
val userId = decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserIdQueryParameterName,
|
||||
UserId.serializer()
|
||||
) ?: return@get
|
||||
val userRole = decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserRoleQueryParameterName,
|
||||
serializer
|
||||
) ?: return@get
|
||||
unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.contains(userId, userRole)
|
||||
)
|
||||
}
|
||||
|
||||
get(usersRolesContainsAnyPathPart) {
|
||||
val userId = decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserIdQueryParameterName,
|
||||
UserId.serializer()
|
||||
) ?: return@get
|
||||
val userRoles = decodeUrlQueryValueOrSendError(
|
||||
usersRolesUserRoleQueryParameterName,
|
||||
userRolesSerializer
|
||||
) ?: return@get
|
||||
unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.containsAny(userId, userRoles)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,37 +13,40 @@ class UsersRolesStorageWriteServerRoutesConfigurator<T : UserRole>(
|
||||
private val storage: WriteUsersRolesStorage<T>,
|
||||
private val serializer: KSerializer<T>,
|
||||
private val includeAuthKey: String,
|
||||
private val excludeAuthKey: String = includeAuthKey
|
||||
private val excludeAuthKey: String = includeAuthKey,
|
||||
private val unifiedRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
override fun Route.invoke() {
|
||||
route(usersRolesRootPathPart) {
|
||||
val wrapperSerializer = UserRolesStorageIncludeExcludeWrapper.serializer(
|
||||
serializer
|
||||
)
|
||||
authenticate(includeAuthKey) {
|
||||
post(usersRolesIncludePathPart) {
|
||||
val wrapper = call.uniload(wrapperSerializer)
|
||||
unifiedRouter.apply {
|
||||
route(usersRolesRootPathPart) {
|
||||
val wrapperSerializer = UserRolesStorageIncludeExcludeWrapper.serializer(
|
||||
serializer
|
||||
)
|
||||
authenticate(includeAuthKey) {
|
||||
post(usersRolesIncludePathPart) {
|
||||
val wrapper = uniload(wrapperSerializer)
|
||||
|
||||
call.unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.include(
|
||||
wrapper.userId,
|
||||
wrapper.userRole
|
||||
unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.include(
|
||||
wrapper.userId,
|
||||
wrapper.userRole
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
authenticate(excludeAuthKey) {
|
||||
post(usersRolesExcludePathPart) {
|
||||
val wrapper = call.uniload(wrapperSerializer)
|
||||
authenticate(excludeAuthKey) {
|
||||
post(usersRolesExcludePathPart) {
|
||||
val wrapper = uniload(wrapperSerializer)
|
||||
|
||||
call.unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.exclude(
|
||||
wrapper.userId,
|
||||
wrapper.userRole
|
||||
unianswer(
|
||||
Boolean.serializer(),
|
||||
storage.exclude(
|
||||
wrapper.userId,
|
||||
wrapper.userRole
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.postssystem.features.users.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.UnifiedRouter
|
||||
import dev.inmo.postssystem.features.users.common.*
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||
import dev.inmo.micro_utils.repos.ktor.server.crud.configureReadStandardCrudRepoRoutes
|
||||
@@ -9,7 +10,8 @@ import io.ktor.routing.route
|
||||
import kotlinx.serialization.builtins.nullable
|
||||
|
||||
class UsersStorageServerRoutesConfigurator(
|
||||
private val usersStorage: ReadUsersStorage
|
||||
private val usersStorage: ReadUsersStorage,
|
||||
private val unifiedRouter: UnifiedRouter
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
override fun Route.invoke() {
|
||||
authenticate {
|
||||
@@ -18,7 +20,8 @@ class UsersStorageServerRoutesConfigurator(
|
||||
usersStorage,
|
||||
User.serializer(),
|
||||
User.serializer().nullable,
|
||||
UserId.serializer()
|
||||
UserId.serializer(),
|
||||
unifiedRouter
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user