diff --git a/backend/.dockerignore b/backend/.dockerignore
new file mode 100644
index 0000000..6c0158d
--- /dev/null
+++ b/backend/.dockerignore
@@ -0,0 +1,57 @@
+### Gradle template
+.gradle
+**/build/
+!src/**/build/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Avoid ignore Gradle wrappper properties
+!gradle-wrapper.properties
+
+# Cache of project
+.gradletasknamecache
+
+# Eclipse Gradle plugin generated files
+# Eclipse Core
+.project
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+### Kotlin template
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+replay_pid*
+
+
+### Custom
+
+.idea/
+.kotlin/
+data/
+compose.yaml
+src/main/resources/.env
diff --git a/backend/Dockerfile b/backend/Dockerfile
new file mode 100644
index 0000000..e18acc0
--- /dev/null
+++ b/backend/Dockerfile
@@ -0,0 +1,8 @@
+FROM gradle:jdk17
+
+WORKDIR /app
+COPY --chown=gradle:gradle . .
+
+RUN gradle buildFatJar
+
+CMD ["gradle", "runFatJar"]
diff --git a/backend/src/main/kotlin/Application.kt b/backend/src/main/kotlin/Application.kt
index 6c5fbd6..581cef1 100644
--- a/backend/src/main/kotlin/Application.kt
+++ b/backend/src/main/kotlin/Application.kt
@@ -23,7 +23,9 @@ fun main() {
}
fun Application.module() {
- val dotenv = dotenv()
+ val dotenv = dotenv {
+ ignoreIfMissing = true
+ }
configureHTTP()
configureErrors()
diff --git a/backend/src/main/resources/logback.xml b/backend/src/main/resources/logback.xml
index aadef5d..7b7cb82 100644
--- a/backend/src/main/resources/logback.xml
+++ b/backend/src/main/resources/logback.xml
@@ -1,7 +1,7 @@
- %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+ %d{YYYY-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
@@ -9,4 +9,4 @@
-
\ No newline at end of file
+
diff --git a/backend/src/test/kotlin/ApplicationTest.kt b/backend/src/test/kotlin/ApplicationTest.kt
index 64cc7af..fe8bf2b 100644
--- a/backend/src/test/kotlin/ApplicationTest.kt
+++ b/backend/src/test/kotlin/ApplicationTest.kt
@@ -7,15 +7,14 @@ import kotlin.test.Test
import kotlin.test.assertEquals
class ApplicationTest {
-
@Test
fun testRoot() = testApplication {
application {
module()
}
+
client.get("/").apply {
assertEquals(HttpStatusCode.OK, status)
}
}
-
}
diff --git a/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt b/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt
index e4ad573..a102ce6 100644
--- a/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt
+++ b/frontend/app/src/main/java/dev/svitan/antifed/AuthActivity.kt
@@ -38,6 +38,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import dev.svitan.antifed.ui.theme.AntiFedTheme
+import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.http.HttpStatusCode
import kotlinx.coroutines.delay
@@ -56,6 +57,12 @@ class AuthActivity : ComponentActivity() {
var checkingUrl by remember { mutableStateOf(false) }
var isServerUrlOk by remember { mutableStateOf(false) }
+ var needToCheckToken by remember { mutableStateOf(false) }
+ var checkingToken by remember { mutableStateOf(false) }
+ var isTokenOk by remember { mutableStateOf(false) }
+
+ var auths by remember { mutableStateOf(listOf()) }
+
val prefs = LocalContext.current.getSharedPreferences(
stringResource(R.string.settings_prefs_key),
MODE_PRIVATE
@@ -68,7 +75,7 @@ class AuthActivity : ComponentActivity() {
fun serverUrlMatches(): Boolean {
var re = Regex(
- "(?:http[s]?:\\/\\/.)?(?:www\\.)?[-a-zA-Z0-9@%._\\+~#=]{2,256}\\.[a-z]{2,6}\\b(?:[-a-zA-Z0-9@:%_\\+.~#?&\\/\\/=]*)",
+ """https?://[a-zA-Z0-9\\.]+\\.[a-zA-Z0-9]+""",
RegexOption.DOT_MATCHES_ALL
)
return re.containsMatchIn(serverUrl)
@@ -89,7 +96,6 @@ class AuthActivity : ComponentActivity() {
delay(1000)
checkingUrl = true
-
val response = client.get(serverUrl)
checkingUrl = false
@@ -101,11 +107,34 @@ class AuthActivity : ComponentActivity() {
}
}
+ LaunchedEffect(token) {
+ if (!needToCheckToken) return@LaunchedEffect
+ else isTokenOk = false
+
+ if (!isServerUrlOk) return@LaunchedEffect
+ if (token.isBlank()) return@LaunchedEffect
+
+ delay(1000)
+ checkingToken = true
+
+ val response = client.get("$serverUrl/auth")
+ if (response.status != HttpStatusCode.OK) {
+ checkingToken = false
+ needToCheckToken = false
+ isTokenOk = false
+ return@LaunchedEffect
+ }
+
+ auths = response.body>()
+ checkingToken = false
+ needToCheckToken = false
+ isTokenOk = true
+ }
+
Scaffold(
topBar = {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
- containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary
),
title = {
@@ -159,13 +188,19 @@ class AuthActivity : ComponentActivity() {
TextField(
value = token,
- onValueChange = { token = it },
+ onValueChange = {
+ needToCheckToken = true
+ token = it
+ },
label = { Text(stringResource(R.string.token)) },
singleLine = true,
isError = token.isBlank(),
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password)
)
+ Spacer(modifier = Modifier.height(12.dp))
+
+ Text("auths: $auths")
}
}
}
diff --git a/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt b/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt
index 35920b9..05abb10 100644
--- a/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt
+++ b/frontend/app/src/main/java/dev/svitan/antifed/MainActivity.kt
@@ -90,7 +90,6 @@ class MainActivity : ComponentActivity() {
topBar = {
TopAppBar(
colors = TopAppBarDefaults.topAppBarColors(
- containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary
),
title = {