From 6e09919c45b02a2f9c984b5960d18912c63f3d35 Mon Sep 17 00:00:00 2001 From: akuleshov7 Date: Sun, 8 Sep 2024 11:50:25 +0300 Subject: [PATCH] Hotfixes for invalid ID length and undefined validation --- .../kotlin/ru/posidata/backend/service/TelegramAuthService.kt | 2 +- .../src/jsMain/kotlin/ru/posidata/views/main/QuestionCard.kt | 2 +- .../src/jsMain/kotlin/ru/posidata/views/main/ResultCard.kt | 2 +- frontend/src/jsMain/kotlin/ru/posidata/views/main/Welcome.kt | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/main/kotlin/ru/posidata/backend/service/TelegramAuthService.kt b/backend/src/main/kotlin/ru/posidata/backend/service/TelegramAuthService.kt index 7e4b233..072231f 100644 --- a/backend/src/main/kotlin/ru/posidata/backend/service/TelegramAuthService.kt +++ b/backend/src/main/kotlin/ru/posidata/backend/service/TelegramAuthService.kt @@ -11,7 +11,7 @@ class TelegramAuthService( @Value("\${telegram.bot.token}") private val telegramToken: String, ) { fun isValidHash(parsedData: Map, hash: String): Boolean { - val dataKeys = parsedData.keys.filter { it != "hash" }.sorted() + val dataKeys = parsedData.keys.filter { it != "hash" }.filter { parsedData[it] != "undefined" }.sorted() val items = dataKeys.map { key -> "$key=${parsedData[key]}" } val dataCheckString = items.joinToString("\n") diff --git a/frontend/src/jsMain/kotlin/ru/posidata/views/main/QuestionCard.kt b/frontend/src/jsMain/kotlin/ru/posidata/views/main/QuestionCard.kt index 69e77f1..3b432c2 100644 --- a/frontend/src/jsMain/kotlin/ru/posidata/views/main/QuestionCard.kt +++ b/frontend/src/jsMain/kotlin/ru/posidata/views/main/QuestionCard.kt @@ -52,7 +52,7 @@ val questionCard = FC { props -> when { response.ok -> props.setUser(response.decodeFromJsonString()) - else -> window.alert("Failed to login with telegram") + else -> window.alert("Failed to validate with telegram") } } } diff --git a/frontend/src/jsMain/kotlin/ru/posidata/views/main/ResultCard.kt b/frontend/src/jsMain/kotlin/ru/posidata/views/main/ResultCard.kt index a8b5f7d..618df6c 100644 --- a/frontend/src/jsMain/kotlin/ru/posidata/views/main/ResultCard.kt +++ b/frontend/src/jsMain/kotlin/ru/posidata/views/main/ResultCard.kt @@ -49,7 +49,7 @@ val resultCard = FC { props -> when { response.ok -> props.setUser(response.decodeFromJsonString()) - else -> window.alert("Failed to login with telegram") + else -> window.alert("Failed to validate with telegram") } } } diff --git a/frontend/src/jsMain/kotlin/ru/posidata/views/main/Welcome.kt b/frontend/src/jsMain/kotlin/ru/posidata/views/main/Welcome.kt index 6d4a765..a67224a 100644 --- a/frontend/src/jsMain/kotlin/ru/posidata/views/main/Welcome.kt +++ b/frontend/src/jsMain/kotlin/ru/posidata/views/main/Welcome.kt @@ -39,13 +39,14 @@ val welcomeCard = FC { props -> response.ok -> { props.setUser(response.decodeFromJsonString()) } - else -> window.alert("Failed to login with telegram") + else -> window.alert("Failed to validate with telegram") } } props.setSelection(Selection.QUESTION) } // just a small test +/* div { button { onClick = { @@ -71,6 +72,7 @@ val welcomeCard = FC { props -> } } } +*/ div {