fixes in auth
This commit is contained in:
parent
f835dc1557
commit
b73df49925
@ -8,8 +8,9 @@ import dev.inmo.postssystem.features.auth.client.ui.*
|
||||
import dev.inmo.postssystem.features.common.common.*
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMExceptionHandler
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMState
|
||||
import kotlin.js.JsExport
|
||||
|
||||
val defaultModuleLoader = DefaultModuleLoader {
|
||||
internal fun CommonAuthModuleLoader() = DefaultModuleLoader {
|
||||
single<AuthSettings> { DefaultAuthSettings(get(DefaultQualifiers.SettingsQualifier), get(), getKoin(), get()) }
|
||||
|
||||
singleWithRandomQualifier {
|
||||
|
@ -29,7 +29,7 @@ val loader = DefaultModuleLoader {
|
||||
strictlyOn(get<AuthView>())
|
||||
}
|
||||
}
|
||||
}
|
||||
} + CommonAuthModuleLoader()
|
||||
|
||||
class AuthView(
|
||||
private val viewModel: AuthUIViewModel,
|
||||
|
@ -2,7 +2,7 @@ package dev.inmo.postssystem.features.auth.server
|
||||
|
||||
import dev.inmo.postssystem.features.auth.common.*
|
||||
import dev.inmo.postssystem.features.auth.server.tokens.AuthTokensService
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.common.server.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.users.common.User
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import dev.inmo.micro_utils.ktor.server.*
|
||||
|
@ -49,12 +49,16 @@ fun baseKoin(
|
||||
single { repoFactory() }
|
||||
single { defaultScope }
|
||||
single(DefaultQualifiers.UIScopeQualifier) { get<CoroutineScope>().LinkedSupervisorScope(Dispatchers.Main) }
|
||||
single<StatesMachine<UIFSMState>>(UIFSMQualifier) { UIFSM(get()) { (this@single to this@UIFSM).apply(get(
|
||||
DefaultQualifiers.FSMHandlersBuilderQualifier
|
||||
)) } }
|
||||
|
||||
AdditionalModules.Default.modules.forEach {
|
||||
it.apply { load() }
|
||||
single<StatesMachine<UIFSMState>>(DefaultQualifiers.UIFSMQualifier) {
|
||||
UIFSM(get()) {
|
||||
(this@single to this@UIFSM).apply(get(DefaultQualifiers.FSMHandlersBuilderQualifier))
|
||||
}
|
||||
}
|
||||
} + AdditionalModules.Default.modules.map {
|
||||
module {
|
||||
with(it) {
|
||||
load()
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -6,5 +6,5 @@ object DefaultQualifiers {
|
||||
val SettingsQualifier = StringQualifier("Settings")
|
||||
val FSMHandlersBuilderQualifier = StringQualifier("FSMHandlersBuilder")
|
||||
val UIScopeQualifier = StringQualifier("CoroutineScopeUI")
|
||||
val UIFSMQualifier = StringQualifier("FSM")
|
||||
val UIFSMQualifier = StringQualifier("UIFSM")
|
||||
}
|
||||
|
@ -12,6 +12,15 @@ interface ModuleLoader {
|
||||
}
|
||||
}
|
||||
|
||||
operator fun ModuleLoader.plus(other: ModuleLoader) = ModuleLoader.ByCallback {
|
||||
with(this@plus) {
|
||||
load()
|
||||
}
|
||||
with (other) {
|
||||
load()
|
||||
}
|
||||
}
|
||||
|
||||
fun DefaultModuleLoader(loadingBlock: Module.() -> Unit): ModuleLoader.ByCallback {
|
||||
val newModuleLoader = ModuleLoader.ByCallback(loadingBlock)
|
||||
AdditionalModules.Default.addModule(newModuleLoader)
|
||||
|
@ -6,8 +6,6 @@ import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
||||
import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManagerRepo
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
val UIFSMQualifier = StringQualifier("UIFSM")
|
||||
|
||||
fun UIFSM(
|
||||
repo: DefaultStatesManagerRepo<UIFSMState>,
|
||||
handlersSetter: FSMBuilder<UIFSMState>.() -> Unit
|
||||
|
@ -1,4 +1,4 @@
|
||||
package dev.inmo.postssystem.features.common.server.sessions
|
||||
package dev.inmo.postssystem.features.common.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.KtorApplicationConfigurator
|
||||
import io.ktor.server.application.Application
|
@ -1,8 +1,9 @@
|
||||
package dev.inmo.postssystem.features.common.server.sessions
|
||||
package dev.inmo.postssystem.features.common.server
|
||||
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
|
||||
object Qualifiers {
|
||||
val filesFolderQualifier = StringQualifier("filesFolder")
|
||||
val commonFilesFolderQualifier = StringQualifier("commonFilesFolder")
|
||||
val usersRolesKeyValueFactoryQualifier = StringQualifier("usersRolesKeyValueFactory")
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package dev.inmo.postssystem.features.common.server.sessions
|
||||
package dev.inmo.postssystem.features.common.server
|
||||
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.module.Module
|
@ -3,8 +3,8 @@ package dev.inmo.postssystem.features.content.binary.server
|
||||
import dev.inmo.micro_utils.repos.exposed.keyvalue.ExposedKeyValueRepo
|
||||
import dev.inmo.postssystem.features.common.common.singleWithBinds
|
||||
import dev.inmo.postssystem.features.common.common.singleWithRandomQualifier
|
||||
import dev.inmo.postssystem.features.common.server.sessions.Qualifiers
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.common.server.Qualifiers
|
||||
import dev.inmo.postssystem.features.common.server.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.content.common.BinaryContent
|
||||
import dev.inmo.postssystem.features.content.server.ServerContentStorageWrapper
|
||||
import dev.inmo.postssystem.features.files.common.*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.postssystem.features.content.text.server
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.singleWithRandomQualifier
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.common.server.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.content.common.ContentSerializersModuleConfigurator
|
||||
import dev.inmo.postssystem.features.content.server.ServerContentStorageWrapper
|
||||
import dev.inmo.postssystem.features.content.text.common.TextContent
|
||||
|
@ -3,7 +3,7 @@ package dev.inmo.postssystem.features.roles.server
|
||||
import dev.inmo.postssystem.features.auth.common.AuthToken
|
||||
import dev.inmo.postssystem.features.auth.server.principal
|
||||
import dev.inmo.postssystem.features.auth.server.tokens.AuthTokensService
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.common.server.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.roles.common.Role
|
||||
import dev.inmo.postssystem.features.roles.common.RolesStorage
|
||||
import io.ktor.http.HttpStatusCode
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
kotlin = "1.6.21"
|
||||
kotlin-serialization = "1.3.3"
|
||||
jsuikit = "0.1.1"
|
||||
jsuikit = "0.1.3"
|
||||
compose = "1.2.0-alpha01-dev686"
|
||||
microutils = "0.10.4"
|
||||
microutils = "0.10.5"
|
||||
tgbotapi = "1.1.2"
|
||||
ktor = "2.0.1"
|
||||
klock = "2.7.0"
|
||||
|
@ -2,7 +2,7 @@ package dev.inmo.postssystem.publicators.simple.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||
import dev.inmo.postssystem.features.common.common.singleWithRandomQualifier
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.common.server.ServerModuleLoader
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import org.koin.core.module.Module
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.common.server.ServerModuleLoader
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.io.File
|
||||
|
@ -3,10 +3,9 @@ package dev.inmo.postssystem.server
|
||||
import dev.inmo.postssystem.features.auth.server.AuthenticationRoutingConfigurator
|
||||
import dev.inmo.postssystem.features.auth.server.SessionAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.auth.server.tokens.*
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.common.server.ApplicationAuthenticationConfigurator
|
||||
import dev.inmo.postssystem.features.files.common.*
|
||||
import dev.inmo.postssystem.features.files.common.storage.*
|
||||
import dev.inmo.postssystem.features.files.common.storage.WriteFilesStorage
|
||||
import dev.inmo.postssystem.features.files.server.FilesRoutingConfigurator
|
||||
import dev.inmo.postssystem.features.roles.common.*
|
||||
import dev.inmo.postssystem.features.roles.common.keyvalue.KeyValuesRolesOriginalRepo
|
||||
@ -25,7 +24,7 @@ import dev.inmo.micro_utils.ktor.server.createKtorServer
|
||||
import dev.inmo.micro_utils.repos.exposed.keyvalue.ExposedKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.onetomany.ExposedOneToManyKeyValueRepo
|
||||
import dev.inmo.postssystem.features.common.common.*
|
||||
import dev.inmo.postssystem.features.common.server.sessions.Qualifiers
|
||||
import dev.inmo.postssystem.features.common.server.Qualifiers
|
||||
import dev.inmo.postssystem.features.content.common.*
|
||||
import dev.inmo.postssystem.features.content.server.ServerContentStorageAggregator
|
||||
import dev.inmo.postssystem.features.content.server.storage.*
|
||||
@ -49,6 +48,7 @@ import org.jetbrains.exposed.sql.Database
|
||||
import org.koin.core.module.Module
|
||||
import org.koin.core.parameter.ParametersHolder
|
||||
import org.koin.core.qualifier.StringQualifier
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.*
|
||||
import java.io.File
|
||||
|
||||
@ -94,6 +94,7 @@ fun getDIModule(
|
||||
singleWithBinds { get<Config>().databaseConfig }
|
||||
singleWithBinds { get<Config>().authConfig }
|
||||
singleWithBinds(Qualifiers.filesFolderQualifier) { get<Config>().filesFolderFile }
|
||||
singleWithBinds(Qualifiers.commonFilesFolderQualifier) { File(get<Config>().filesFolderFile, "common").apply { mkdirs() } }
|
||||
|
||||
singleWithBinds { get<DatabaseConfig>().database }
|
||||
singleWithBinds { ExposedUsersStorage(get()) }
|
||||
@ -141,6 +142,17 @@ fun getDIModule(
|
||||
)
|
||||
}
|
||||
|
||||
singleWithBinds<FilesStorage> {
|
||||
val metasRepo = MetasKeyValueRepo(
|
||||
get(),
|
||||
ExposedKeyValueRepo(get(), { text("fileid") }, { text("metaInfo") }, "CommonFilesMetaInfoTable")
|
||||
)
|
||||
DefaultFilesStorage(
|
||||
DiskReadFilesStorage(get(Qualifiers.commonFilesFolderQualifier), metasRepo),
|
||||
WriteDistFilesStorage(get(Qualifiers.commonFilesFolderQualifier), metasRepo)
|
||||
)
|
||||
}
|
||||
|
||||
// Routing configurators
|
||||
singleWithBinds { FilesRoutingConfigurator(get(), null, get()) }
|
||||
singleWithBinds { StatusRoutingConfigurator }
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dev.inmo.postssystem.targets.telegram.loader.server
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.singleWithRandomQualifier
|
||||
import dev.inmo.postssystem.features.common.server.sessions.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.common.server.ServerModuleLoader
|
||||
import dev.inmo.postssystem.features.content.common.ContentSerializersModuleConfigurator
|
||||
import dev.inmo.postssystem.features.publication.server.PublicationTarget
|
||||
import dev.inmo.postssystem.targets.telegram.content.polls.common.PollContent
|
||||
|
Loading…
Reference in New Issue
Block a user