From bafb63dc16fa2ac84b47023377eafecc2ec27988 Mon Sep 17 00:00:00 2001 From: StefanMoCoAt Date: Tue, 17 Mar 2026 00:18:02 +0100 Subject: [PATCH] Remove deprecated `isAuthenticated` logic from PingViewModel and related UI components --- docs/05_Backend/Guides/Testing_with_Postman.md | 2 +- .../at/mocode/ping/feature/presentation/PingScreen.kt | 10 ++++------ .../mocode/ping/feature/presentation/PingViewModel.kt | 6 ------ .../src/commonMain/kotlin/MainApp.kt | 4 +--- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/docs/05_Backend/Guides/Testing_with_Postman.md b/docs/05_Backend/Guides/Testing_with_Postman.md index f524d63d..6ab5e334 100644 --- a/docs/05_Backend/Guides/Testing_with_Postman.md +++ b/docs/05_Backend/Guides/Testing_with_Postman.md @@ -46,7 +46,7 @@ Setze folgende Variablen in Postman (Environment "Local Docker"): * `client_id`: `postman-client` * `client_secret`: `postman-secret-123` * `username`: `admin` -* `password`: `Change_Me_In_Production!` +* `password`: `Admin#1234` --- diff --git a/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingScreen.kt b/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingScreen.kt index 57cb3cb1..87e626ca 100644 --- a/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingScreen.kt +++ b/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingScreen.kt @@ -22,10 +22,8 @@ import at.mocode.frontend.core.designsystem.theme.Dimens @Composable fun PingScreen( viewModel: PingViewModel, - onBack: () -> Unit = {}, - isAuthenticated: Boolean = false + onBack: () -> Unit = {} ) { - viewModel.isAuthenticated = isAuthenticated val uiState = viewModel.uiState // Wir nutzen jetzt das globale Theme (Hintergrund kommt vom Theme) @@ -53,7 +51,7 @@ fun PingScreen( .fillMaxHeight() .padding(end = Dimens.SpacingS) ) { - ActionToolbar(viewModel, isAuthenticated) + ActionToolbar(viewModel) Spacer(Modifier.height(Dimens.SpacingS)) StatusGrid(uiState) } @@ -133,7 +131,7 @@ private fun StatusBadge(text: String, color: Color) { } @Composable -private fun ActionToolbar(viewModel: PingViewModel, isAuthenticated: Boolean) { +private fun ActionToolbar(viewModel: PingViewModel) { // Wrap buttons to avoid overflow on small screens Row( modifier = Modifier.fillMaxWidth(), @@ -141,7 +139,7 @@ private fun ActionToolbar(viewModel: PingViewModel, isAuthenticated: Boolean) { ) { DenseButton(text = "Simple", onClick = { viewModel.performSimplePing() }) DenseButton(text = "Enhanced", onClick = { viewModel.performEnhancedPing() }) - DenseButton(text = "Secure", onClick = { viewModel.performSecurePing() }, enabled = isAuthenticated) + DenseButton(text = "Secure", onClick = { viewModel.performSecurePing() }) DenseButton(text = "Health", onClick = { viewModel.performHealthCheck() }) DenseButton( text = "Sync", diff --git a/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingViewModel.kt b/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingViewModel.kt index a3d65895..c24b8547 100644 --- a/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingViewModel.kt +++ b/frontend/features/ping-feature/src/commonMain/kotlin/at/mocode/ping/feature/presentation/PingViewModel.kt @@ -41,8 +41,6 @@ class PingViewModel( var uiState by mutableStateOf(PingUiState()) private set - var isAuthenticated: Boolean = false - private fun addLog(source: String, message: String, isError: Boolean = false) { val now = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()) val timeString = "${now.hour.toString().padStart(2, '0')}:${now.minute.toString().padStart(2, '0')}:${ @@ -110,10 +108,6 @@ class PingViewModel( } fun performSecurePing() { - if (!isAuthenticated) { - addLog("SecurePing", "Not authenticated – request blocked.", isError = true) - return - } viewModelScope.launch { uiState = uiState.copy(isLoading = true, errorMessage = null) addLog("SecurePing", "Sending authenticated request...") diff --git a/frontend/shells/meldestelle-portal/src/commonMain/kotlin/MainApp.kt b/frontend/shells/meldestelle-portal/src/commonMain/kotlin/MainApp.kt index 8056eb1a..e668e92a 100644 --- a/frontend/shells/meldestelle-portal/src/commonMain/kotlin/MainApp.kt +++ b/frontend/shells/meldestelle-portal/src/commonMain/kotlin/MainApp.kt @@ -36,7 +36,6 @@ fun MainApp() { // Delta-Sync blueprint: resolve the Ping feature view model via Koin. val pingViewModel: PingViewModel = koinViewModel() val loginViewModel: LoginViewModel = koinViewModel() - val authState by authTokenManager.authState.collectAsState() when (currentScreen) { is AppScreen.Landing -> LandingScreen( @@ -59,8 +58,7 @@ fun MainApp() { is AppScreen.Ping -> PingScreen( viewModel = pingViewModel, - onBack = { navigationPort.navigateToScreen(AppScreen.Home) }, - isAuthenticated = authState.isAuthenticated + onBack = { navigationPort.navigateToScreen(AppScreen.Home) } // Navigate back to Home ) is AppScreen.Profile -> AuthStatusScreen(