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