aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2022-01-15 01:10:32 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2022-01-15 01:10:32 -0600
commit416e39decb2183ed0387863cec638be2df5f8bdd (patch)
tree50c337facc7f2a9aef0ddd08588e167f3d50ebc9 /shared/src/commonMain/kotlin/mx/trackermap
parentff8074a32925dd51bcb29e630104ff031b29df75 (diff)
downloadetbsa-trackermap-mobile-416e39decb2183ed0387863cec638be2df5f8bdd.tar.gz
etbsa-trackermap-mobile-416e39decb2183ed0387863cec638be2df5f8bdd.tar.bz2
etbsa-trackermap-mobile-416e39decb2183ed0387863cec638be2df5f8bdd.zip
Fixes the 401 error while registering the FCM token
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt1
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt6
2 files changed, 4 insertions, 3 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
index 2fba8a8..b57f126 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt
@@ -107,6 +107,7 @@ class SessionApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(
.flatten()
.find { it.contains("JSESSIONID") }!!
.replace("; Path=/", "")
+ this.token = cookie
val settings = Settings()
settings.putString(ACCESS_TOKEN_KEY, cookie)
(response as Success<*>).data as User
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
index b9cf335..da9b115 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt
@@ -73,9 +73,9 @@ class SessionController(
loginStateFlow.value = LoginState.Loading
GlobalScope.launch {
try {
- userFlow.value = sessionApi.sessionPost(email, password)
- delay(3000)
- Log.d("LoginViewModel", userFlow.value.toString())
+ val session = sessionApi.sessionPost(email, password)
+ userFlow.value = session
+ usersApi.token = sessionApi.token
token?.let { registerFcmToken(it) }
loginStateFlow.value = LoginState.Success
} catch (e: Exception) {