fix: wrap browser opening in withContext(Dispatchers.IO) for JVM OIDC callback
Ensures proper threading for desktop actions, preventing potential blocking issues during browser invocation. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+6
-1
@@ -2,7 +2,10 @@ package at.mocode.frontend.core.auth.data
|
|||||||
|
|
||||||
import com.sun.net.httpserver.HttpServer
|
import com.sun.net.httpserver.HttpServer
|
||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.coroutines.withTimeoutOrNull
|
import kotlinx.coroutines.withTimeoutOrNull
|
||||||
|
import java.awt.Desktop
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
@@ -59,7 +62,9 @@ actual suspend fun launchOidcFlow(
|
|||||||
|
|
||||||
// Browser öffnen
|
// Browser öffnen
|
||||||
try {
|
try {
|
||||||
java.awt.Desktop.getDesktop().browse(URI(authUrl))
|
withContext(Dispatchers.IO) {
|
||||||
|
Desktop.getDesktop().browse(URI(authUrl))
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
server.stop(0)
|
server.stop(0)
|
||||||
return OidcCallbackResult.Error("browser_error", "Browser konnte nicht geöffnet werden: ${e.message}")
|
return OidcCallbackResult.Error("browser_error", "Browser konnte nicht geöffnet werden: ${e.message}")
|
||||||
|
|||||||
Reference in New Issue
Block a user